Text Generation
Transformers
Safetensors
English
mistral
text-generation-inference
unsloth
conversational
Instructions to use Prod5/mistral-7b-a2ui with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Prod5/mistral-7b-a2ui with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Prod5/mistral-7b-a2ui") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Prod5/mistral-7b-a2ui") model = AutoModelForCausalLM.from_pretrained("Prod5/mistral-7b-a2ui", device_map="auto") 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Prod5/mistral-7b-a2ui with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Prod5/mistral-7b-a2ui" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Prod5/mistral-7b-a2ui", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Prod5/mistral-7b-a2ui
- SGLang
How to use Prod5/mistral-7b-a2ui 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 "Prod5/mistral-7b-a2ui" \ --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": "Prod5/mistral-7b-a2ui", "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 "Prod5/mistral-7b-a2ui" \ --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": "Prod5/mistral-7b-a2ui", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use Prod5/mistral-7b-a2ui with Docker Model Runner:
docker model run hf.co/Prod5/mistral-7b-a2ui
Download handler.py from Prod5/mistral-7b-a2ui: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/Prod5/mistral-7b-a2ui/resolve/main/handler.py
- Command line
-
hf download hf://Prod5/mistral-7b-a2ui/handler.py
-
curl -L -o handler.py https://huggingface.co/Prod5/mistral-7b-a2ui/resolve/main/handler.py
812 Bytes
| from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline | |
| import torch | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| self.tokenizer = AutoTokenizer.from_pretrained(path) | |
| self.model = AutoModelForCausalLM.from_pretrained( | |
| path, | |
| torch_dtype=torch.float16, | |
| device_map="auto", | |
| ) | |
| self.pipeline = pipeline( | |
| "text-generation", | |
| model=self.model, | |
| tokenizer=self.tokenizer, | |
| ) | |
| def __call__(self, data): | |
| inputs = data.get("inputs", "") | |
| parameters = data.get("parameters", {}) | |
| if not parameters.get("max_new_tokens"): | |
| parameters["max_new_tokens"] = 2048 | |
| result = self.pipeline(inputs, **parameters) | |
| return result | |