Comments (3)
what is the version of langchain and ipex-llm are you using?
from bigdl.
Seems you're running this example on CPU? maybe you can try follow this example to load low bit model. https://github.com/intel-analytics/ipex-llm/blob/main/python/llm/example/CPU/LangChain/low_bit.py
from bigdl.
Hi,
We have reviewed your query and used our sample code to address the problem.
Solution:
We utilized our sample code to resolve the issue. Here is the relevant section of our sample code that addresses your issue:
import argparse
from ipex_llm.langchain.llms import TransformersLLM, TransformersPipelineLLM
from langchain import PromptTemplate, LLMChain
from langchain import HuggingFacePipeline
def main(args):
question = args.question
model_path = args.model_path
low_bit_model_path = args.target_path
template ="""{question}"""
prompt = PromptTemplate(template=template, input_variables=["question"])
llm = TransformersLLM.from_model_id(
model_id=model_path,
model_kwargs={"temperature": 0, "max_length": 1024, "trust_remote_code": True},
)
llm.model.save_low_bit(low_bit_model_path)
del llm
low_bit_llm = TransformersLLM.from_model_id_low_bit(
model_id=low_bit_model_path,
tokenizer_id=model_path,
model_kwargs={"temperature": 0, "max_length": 1024, "trust_remote_code": True}
)
llm_chain = LLMChain(prompt=prompt, llm=low_bit_llm)
output = llm_chain.run(question)
print("====output=====")
print(output)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='TransformersLLM Langchain Chat Example')
parser.add_argument('-m','--model-path', type=str, required=True,
help='the path to transformers model')
parser.add_argument('-t','--target-path',type=str,required=True,
help='the path to save the low bit model')
parser.add_argument('-q', '--question', type=str, default='What is AI?',
help='qustion you want to ask.')
args = parser.parse_args()
main(args)
And then use this command to run it.
python low_bit.py -m <path_to_model> -t <path_to_target> [-q <your question>]
Runtime Arguments Explained:
-m MODEL_PATH
: Required, the path to the model-t TARGET_PATH
: Required, the path to save the low_bit model-q QUESTION
: the question
Output:
After implementing the solution, we obtained the following output:
Artificial Intelligence (AI) refers to the development of computer systems that can perform tasks that normally require human intelligence, such as visual perception, speech recognition, decision-making, and language translation. AI systems use algorithms and machine learning techniques to analyze data, identify patterns, and make decisions based on that data.
There are different types of AI, including:
1. Narrow AI: Also known as weak AI, this type of AI is designed to perform a specific task, such as voice recognition or image recognition.
2. General AI: Also known as strong AI, this type of AI is designed to perform any intellectual task that a human can do.
3. Superintelligent AI: This is a hypothetical type of AI that is much smarter than the best human minds in virtually all spheres, including scientific creativity, general wisdom, and social skills.
AI is used in various industries, including healthcare, finance, manufacturing, transportation, and education, to improve efficiency, accuracy, and productivity. It can also be used to develop new products and services, enhance customer experiences, and solve complex problems.
However, AI also raises ethical concerns, such as privacy, bias, and job displacement. It is important for organizations and individuals to use AI responsibly and ethically, and to consider the potential impact on society as a whole.
====output=====
What is AI?
Artificial Intelligence (AI) refers to the development of computer systems that can perform tasks that normally require human intelligence, such as visual perception, speech recognition, decision-making, and language translation. AI systems use algorithms and machine learning techniques to analyze data, identify patterns, and make decisions based on that data.
There are different types of AI, including:
1. Narrow AI: Also known as weak AI, this type of AI is designed to perform a specific task, such as voice recognition or image recognition.
2. General AI: Also known as strong AI, this type of AI is designed to perform any intellectual task that a human can do.
3. Superintelligent AI: This is a hypothetical type of AI that is much smarter than the best human minds in virtually all spheres, including scientific creativity, general wisdom, and social skills.
AI is used in various industries, including healthcare, finance, manufacturing, transportation, and education, to improve efficiency, accuracy, and productivity. It can also be used to develop new products and services, enhance customer experiences, and solve complex problems.
However, AI also raises ethical concerns, such as privacy, bias, and job displacement. It is important for organizations and individuals to use AI responsibly and ethically, and to consider the potential impact on society as a whole.
from bigdl.
Related Issues (20)
- inference error: mistral and codellama have issue 'object has no attribute '_has_non_default_generation_parameters' HOT 1
- Incompatible with Streamlit HOT 3
- run "python setup.py bdist_wheel" error HOT 3
- vLLM freezes with gpu-memory-utilization > 0.55 HOT 3
- ollama MTL iGPU issue HOT 7
- Qwen1.5-A2.7B cannot be offload on iGPU HOT 3
- CodeQwen1.5-7B-Chat performance gap between pytorch and gguf
- Segmentation fault when running Deepspeed-AutoTP HOT 2
- Issue while using IPEX-LLM optimized Mixtral model in Langchain agent creation HOT 6
- ipex-llm报错如图片server cpu not listed in available servers map HOT 8
- Error in the process of using HOT 1
- Need modify Deepspeed test script to support Xeon CPU HOT 1
- gemma 2 support HOT 1
- MTL GPU driver not shown and GPU demo crashed on Linux HOT 1
- Generate result token by token when inference. HOT 2
- Unable to Load LLMs in GGUF format HOT 1
- Unable to import LlamaCpp HOT 1
- [Flex170/Whisper]Low GPU usage when running whisper via ipex-llm on Flex170 GPU HOT 3
- Run Llama-2-7B-Chat-hf bigdl_ipex_bf16 Error on Xeon SPR HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigdl.