MahmoudIbrahim/Arabic_NVIDIA
Viewer โข Updated โข 20.3k โข 22 โข 1
How to use MahmoudIbrahim/Mistral_Nemo_Arabic with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="MahmoudIbrahim/Mistral_Nemo_Arabic") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("MahmoudIbrahim/Mistral_Nemo_Arabic")
model = AutoModelForCausalLM.from_pretrained("MahmoudIbrahim/Mistral_Nemo_Arabic")How to use MahmoudIbrahim/Mistral_Nemo_Arabic with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "MahmoudIbrahim/Mistral_Nemo_Arabic"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "MahmoudIbrahim/Mistral_Nemo_Arabic",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/MahmoudIbrahim/Mistral_Nemo_Arabic
How to use MahmoudIbrahim/Mistral_Nemo_Arabic with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "MahmoudIbrahim/Mistral_Nemo_Arabic" \
--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": "MahmoudIbrahim/Mistral_Nemo_Arabic",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "MahmoudIbrahim/Mistral_Nemo_Arabic" \
--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": "MahmoudIbrahim/Mistral_Nemo_Arabic",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use MahmoudIbrahim/Mistral_Nemo_Arabic with Docker Model Runner:
docker model run hf.co/MahmoudIbrahim/Mistral_Nemo_Arabic
Developed by: Mahmoud Ibrahim
How to use :
! pip install transformers bitsandbytes
from transformers import AutoTokenizer, AutoModelForCausalLM
from IPython.display import Markdown
import textwrap
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("MahmoudIbrahim/Mistral_12b_Arabic")
model = AutoModelForCausalLM.from_pretrained("MahmoudIbrahim/Mistral_12b_Arabic",load_in_4bit =True)
alpaca_prompt = """ููู
ุง ููู ุชุนููู
ุงุช ุชุตู ู
ูู
ุฉุ ุฅูู ุฌุงูุจ ู
ุฏุฎู ูููุฑ ุณูุงูุงู ุฅุถุงููุงู. ุงูุชุจ ุงุณุชุฌุงุจุฉ ุชููู
ู ุงูุทูุจ ุจุดูู ู
ูุงุณุจ.
### ุงูุชุนููู
ุงุช:
{}
### ุงูุงุณุชุฌุงุจุฉ:
{}"""
# Format the prompt with instruction and an empty output placeholder
formatted_prompt = alpaca_prompt.format(
"ููู ูู
ูู ููุญููู
ุฉ ุงูู
ุตุฑูุฉ ูุงูู
ุฌุชู
ุน ููู ุฃู ูุนุฒุฒูุง ู
ู ูุฏุฑุฉ ุงูุจูุงุฏ ุนูู ุชุญููู ุงูุชูู
ูุฉ ุงูู
ุณุชุฏุงู
ุฉุ " , # instruction
"" # Leave output blank for generation
)
# Tokenize the formatted string directly
input_ids = tokenizer.encode(formatted_prompt, return_tensors="pt") # Use 'cuda' if you want to run on GPU
def to_markdown(text):
text = text.replace('โข','*')
return Markdown(textwrap.indent(text, '>', predicate=lambda _: True))
# Generate text
output = model.generate(
input_ids,
max_length=128, # Adjust max length as needed
num_return_sequences=1, # Number of generated responses
no_repeat_ngram_size=2, # Prevent repetition
top_k=50, # Filter to top-k tokens
top_p=0.9, # Use nucleus sampling
temperature=0.7 , # Control creativity level
)
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
to_markdown(generated_text)
The model response :
Base model
unsloth/Mistral-Nemo-Base-2407-bnb-4bit