3okasha/synthetic-back-translated-ar-opensubtitle-data-v01
Viewer โข Updated โข 32.6k โข 31
How to use 3okasha/jais-finetuned-v1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="3okasha/jais-finetuned-v1", trust_remote_code=True) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("3okasha/jais-finetuned-v1", trust_remote_code=True, dtype="auto")How to use 3okasha/jais-finetuned-v1 with PEFT:
Task type is invalid.
How to use 3okasha/jais-finetuned-v1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "3okasha/jais-finetuned-v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "3okasha/jais-finetuned-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/3okasha/jais-finetuned-v1
How to use 3okasha/jais-finetuned-v1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "3okasha/jais-finetuned-v1" \
--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": "3okasha/jais-finetuned-v1",
"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 "3okasha/jais-finetuned-v1" \
--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": "3okasha/jais-finetuned-v1",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use 3okasha/jais-finetuned-v1 with Docker Model Runner:
docker model run hf.co/3okasha/jais-finetuned-v1
Model Description:
This model is fine-tuned for paraphrasing Arabic sentences while preserving the original meaning of the sentence. It was trained using the Supervised Fine-Tuning (SFT) method on the Jais-13B model using the TRL library (SFTTrainer) and the PEFT/LoRA library.
# -*- coding: utf-8 -*-
!pip install --upgrade bitsandbytes
!pip install -q datasets
!pip install -q trl
!pip install git+https://github.com/huggingface/peft.git
!pip install -q -U accelerate
from huggingface_hub import login
login()
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import LoraConfig, get_peft_model, prepare_model_for_kbit_training, PeftModel, PeftConfig
from datasets import load_dataset
from transformers import TrainingArguments, pipeline
from trl import SFTTrainer
bnb_cfg = BitsAndBytesConfig(
load_in_8bit=True,
# bnb_4bit_quant_type="nf4",
# bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype="bfloat16",
)
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_path = "3okasha/jais-finetuned-v1"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
quantization_config=bnb_cfg,
device_map="auto",
trust_remote_code=True
)
def user_prompt(human_prompt):
prompt_template=f"input:\n{human_prompt}\n\nparaphrize:\n"
return prompt_template
model.config.use_cache = False
if hasattr(model, "generation_config"): model.generation_config.use_cache = False
def get_response(text,tokenizer=tokenizer,model=model):
input_ids = tokenizer(text, return_tensors="pt").input_ids
inputs = input_ids.to(device)
input_len = inputs.shape[-1]
generate_ids = model.generate(
inputs,
top_p=0.9,
temperature=0.3,
max_length=50-input_len,
min_length=input_len + 4,
repetition_penalty=1.2,
do_sample=True,
)
response = tokenizer.batch_decode(
generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)[0]
return response
text= user_prompt("ุฃุนุชูุฏ ูู
ูููุง ุฃู ูุจุฏุฃ")
print(get_response(text))
## ุฃุนุชูุฏ ุฃูู ูู
ูููุง ุงูุจุฏุฃ
## ุฃุนุชูุฏ ุฃููุง ูู
ูู ุฃู ูุจุฏุฃ
Base model
inceptionai/jais-13b