Instructions to use ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd") model = AutoModelForCausalLM.from_pretrained("ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd
- SGLang
How to use ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd 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 "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd" \ --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": "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd", "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 "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd" \ --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": "ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd with Docker Model Runner:
docker model run hf.co/ysn-rfd/First_Persian_SLM_Big_Update_Version3_ysnrfd
Model Details
WARNINNGS: This Model IS Pre-Trained, in the future will be finetuned.
Model Description
The First Persian SLM By YSNRFD (YASIN ARYANFARD) and AMIRHOSSEIN MEHRDOOST, This Model support Only Persian text Inputs, In The Future I Want Add Englih Language Support.
- Developed by: ysnrfd (yasin aryanfard)
- Funded by: ysnrfd (yasin aryanfard) and Amirhossein Mehrdoost (https://huggingface.co/fibonacciai)
- Shared by: ysnrfd (yasin aryanfard) and Amirhossein Mehrdoost (https://huggingface.co/fibonacciai)
- Model type: SLM
- Language(s) (NLP): Persian
- License: ysnrfd LICENSE
Training Data
ysnrfd Sample Persian Text LINK: https://huggingface.co/datasets/ysn-rfd/fibonacci_alpaca_to_sharegpt_gpt_format_convert_new_dataset_release
Training Hyperparameters
- Training regime: fp32 mixed precision
Evaluation
Not Yet
Testing Data, Factors & Metrics
ysnrfd Sample Persian Text
Testing Data
Not Yet
Summary
The Fisrt Persian SLM Trained From Scratch
- Hardware Type: Nvidia Tesla T4 (1)
- Hours used: 1H
- Cloud Provider: Google Colab
Model Architecture and Objective
YSNRFD Architecture
Hardware
Nvidia Tesla T4
Software
Python Code, From Scratch, Pytorch
Script For Run Model
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
import re
model_path = "./Path_To_Model"
print(f"{model_path}...")
tokenizer = GPT2Tokenizer.from_pretrained(model_path)
model = GPT2LMHeadModel.from_pretrained(model_path)
device = "cuda" if torch.cuda.is_available() else "cpu"
print(f"{device}")
model.to(device)
model.eval()
try:
end_token_id = tokenizer.convert_tokens_to_ids("### End")
if end_token_id == tokenizer.unk_token_id:
end_token_id = None
except:
end_token_id = None
print("\n------+------+------+------ model is ready for testing +------+------++------\n")
print("type exit for exit")
print("\nYSNRFD")
print("------+------+------+----------------------+------+------++------\n")
while True:
user_input = input("\nYou: ").strip()
if user_input.lower() in ["exit"]:
print("\n good bye (ysnrfd)")
break
prompt = f"### Human: {user_input}\n### Assistant:"
inputs = tokenizer(
prompt,
return_tensors="pt",
truncation=True,
max_length=512
).to(device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=400,
temperature=0.7,
top_p=0.9,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=end_token_id or tokenizer.eos_token_id,
repetition_penalty=1.05
)
full_response = tokenizer.decode(outputs[0], skip_special_tokens=False)
assistant_response = full_response[len(prompt):].strip()
if "### End" in assistant_response:
assistant_response = assistant_response.split("### End")[0].strip()
assistant_response = re.sub(r'^###\s*Assistant:\s*', '', assistant_response)
if assistant_response:
print(f"\nBot: {assistant_response}")
else:
print("\nBot: please again say")
- Downloads last month
- 6