Text Generation
Transformers
Safetensors
mistral
finetuned
conversational
text-generation-inference
4-bit precision
awq
Instructions to use TheBloke/Mistral-7B-Instruct-v0.2-AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TheBloke/Mistral-7B-Instruct-v0.2-AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TheBloke/Mistral-7B-Instruct-v0.2-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ") model = AutoModelForCausalLM.from_pretrained("TheBloke/Mistral-7B-Instruct-v0.2-AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use TheBloke/Mistral-7B-Instruct-v0.2-AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TheBloke/Mistral-7B-Instruct-v0.2-AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Mistral-7B-Instruct-v0.2-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TheBloke/Mistral-7B-Instruct-v0.2-AWQ
- SGLang
How to use TheBloke/Mistral-7B-Instruct-v0.2-AWQ with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "TheBloke/Mistral-7B-Instruct-v0.2-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Mistral-7B-Instruct-v0.2-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "TheBloke/Mistral-7B-Instruct-v0.2-AWQ" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TheBloke/Mistral-7B-Instruct-v0.2-AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use TheBloke/Mistral-7B-Instruct-v0.2-AWQ with Docker Model Runner:
docker model run hf.co/TheBloke/Mistral-7B-Instruct-v0.2-AWQ
RAG issue | loading the model in RetrievalQASourceChain
#2
by iammano - opened
Hi there,
I'm getting this error when I try to pass the model to the llm parameter in langchain's RetrievalQASourceChain parameter, Below is my code.
def __init__(self, **kwargs):
"""
Initializes the QA bot with a Qdrant client, embeddings, and a language model.
Parameters:
- **kwargs: Additional keyword arguments for configuration.
"""
self.client = QdrantClient(url=HOST_NAME,api_key=API_KEY)
self.embedding = get_embedding()
self.device = "cuda:0"
if torch.cuda.is_available():
print("Inside GPU")
self.llm = AutoModelForCausalLM.from_pretrained(
HF_MODEL,
low_cpu_mem_usage=True,
device_map=self.device
)
else:
self.llm = CTransformers(model=MODEL_PATH,
model_type=MODEL_TYPE,
config=MODEL_PARAMETERS)
def answer(query):
qa = RetrievalQAWithSourcesChain.from_chain_type(
llm=self.llm,
retriever=retriever,
chain_type_kwargs={
"prompt": my_prompt
},
device_map=self.device,
reduce_k_below_max_tokens=True,
return_source_documents=True)
These are methods of a class that I have shared partial code here. Thanks for your understanding.
Error Message:
Traceback (most recent call last):
File "/home/manoranjan.n/doc_test/backend/main.py", line 68, in ask_model
result = qabot.answer(data['question'])
File "/home/manoranjan.n/doc_test/backend/qa_bot.py", line 227, in answer
qa = RetrievalQAWithSourcesChain.from_chain_type(
File "/home/manoranjan.n/.local/lib/python3.8/site-packages/langchain/chains/qa_with_sources/base.py", line 85, in from_chain_type
combine_documents_chain = load_qa_with_sources_chain(
File "/home/manoranjan.n/.local/lib/python3.8/site-packages/langchain/chains/qa_with_sources/loading.py", line 183, in load_qa_with_sources_chain
return _func(llm, verbose=verbose, **kwargs)
File "/home/manoranjan.n/.local/lib/python3.8/site-packages/langchain/chains/qa_with_sources/loading.py", line 62, in _load_stuff_chain
llm_chain = LLMChain(llm=llm, prompt=prompt, verbose=verbose)
File "/home/manoranjan.n/.local/lib/python3.8/site-packages/langchain_core/load/serializable.py", line 107, in __init__
super().__init__(**kwargs)
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 2 validation errors for LLMChain
llm
instance of Runnable expected (type=type_error.arbitrary_type; expected_arbitrary_type=Runnable)
llm
instance of Runnable expected (type=type_error.arbitrary_type; expected_arbitrary_type=Runnable)
Somekind of validation error, please help me on this.