Instructions to use aidal/Persian-Mistral-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aidal/Persian-Mistral-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aidal/Persian-Mistral-7B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aidal/Persian-Mistral-7B") model = AutoModelForCausalLM.from_pretrained("aidal/Persian-Mistral-7B") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aidal/Persian-Mistral-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aidal/Persian-Mistral-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aidal/Persian-Mistral-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aidal/Persian-Mistral-7B
- SGLang
How to use aidal/Persian-Mistral-7B 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 "aidal/Persian-Mistral-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aidal/Persian-Mistral-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "aidal/Persian-Mistral-7B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aidal/Persian-Mistral-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aidal/Persian-Mistral-7B with Docker Model Runner:
docker model run hf.co/aidal/Persian-Mistral-7B
Facing error when loading tokenizer using AutoTokenizer
#1
by alirezashmo - opened
Hi! I'm facing an issue when trying to load tokenizer:
Traceback (most recent call last):
File "testing_persian_mistral.py", line 54, in <module>
tokenizer = AutoTokenizer.from_pretrained("aidal/Persian-Mistral-7B")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xxxxxxxxxxxxxxxxxxxxxxx\Lib\site-packages\transformers\models\auto\tokenization_auto.py", line 916, in from_pretrained
return tokenizer_class_fast.from_pretrained(pretrained_model_name_or_path, *inputs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "xxxxxxxxxxxxxxxxxxxxxxx\Lib\site-packages\transformers\tokenization_utils_base.py", line 2255, in from_pretrained
raise EnvironmentError(
OSError: Can't load tokenizer for 'aidal/Persian-Mistral-7B'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'aidal/Persian-Mistral-7B' is the correct path to a directory containing all relevant files for a LlamaTokenizerFast tokenizer.
This is my code:
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("aidal/Persian-Mistral-7B") # OSError Error
model = AutoModelForCausalLM.from_pretrained("aidal/Persian-Mistral-7B")
input_text = "پایتخت ایران کجاست؟"
input_ids = tokenizer(input_text, return_tensors="pt")
outputs = model.generate(**input_ids)
print(tokenizer.decode(outputs[0]))
I have even tried to login to hugging face with access token suing huggingface_hub.login and even setting HF_TOKEN env variable. But the problem persists.
Thank you for helping me to fix the problem so that I can use your grate model.
I think the reason you are facing this error is that there are no (tokenizer.json/tokenizer_config.json) files in the directory. So, you need to define a custom tokenizer and configs for this.