microsoft/orca-math-word-problems-200k
Viewer • Updated • 200k • 7.52k • 486
How to use Neurai/NeuraOrcaGemma7b with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Neurai/NeuraOrcaGemma7b")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Neurai/NeuraOrcaGemma7b")
model = AutoModelForCausalLM.from_pretrained("Neurai/NeuraOrcaGemma7b")
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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use Neurai/NeuraOrcaGemma7b with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Neurai/NeuraOrcaGemma7b"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Neurai/NeuraOrcaGemma7b",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Neurai/NeuraOrcaGemma7b
How to use Neurai/NeuraOrcaGemma7b with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Neurai/NeuraOrcaGemma7b" \
--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": "Neurai/NeuraOrcaGemma7b",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "Neurai/NeuraOrcaGemma7b" \
--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": "Neurai/NeuraOrcaGemma7b",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Neurai/NeuraOrcaGemma7b with Docker Model Runner:
docker model run hf.co/Neurai/NeuraOrcaGemma7b
Check out the Google Colab demo to run NeuraOrcaGemma7b on a free-tier Google Colab instance:
make sure these packages are installed:
!pip install --no-deps xformers accelerate bitsandbytes
!pip install -q -U transformers
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import torch
import os
MODEL_PATH = "Neurai/NeuraOrcaGemma7b"
quantization_config = BitsAndBytesConfig(
load_in_4bit = True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_use_double_quant=True,
)
model = AutoModelForCausalLM.from_pretrained(
MODEL_PATH,
device_map = "auto",
trust_remote_code = True,
quantization_config=quantization_config,
)
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
input_prompt = """
### Instruction:{}
### Input:{}
### Response:{}"""
input_text = input_prompt.format(
"در مورد سری فوریه بهم توضیح میدی و فرمولش رو برام مینویسی",
"",
""
)
inputs = tokenizer([input_text], return_tensors = "pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens = 300, use_cache = True)
response = tokenizer.batch_decode(outputs)[0]
Generated text :
سری فوریه یک سری ریاضی است که برای نمایش یک تابع پیوسته و متناوب در یک بازه زمانی معین استفاده می شود. این نام از ریاضیدان فرانسوی آگوستین-لویی کوشی گرفته شده است که آن را در سال 1826 معرفی کرد.
فرمول سری فوریه به صورت زیر است:
f(x) = a0 + sum(an * cos(n*pi*x/L)) + sum(bn * sin(n*pi*x/L))
که در آن:
- f(x) تابع پیوسته و متناوب در بازه زمانی [(-L/2, L/2] است
- a0 مقدار میانگین مربع f(x) در بازه زمانی [(-L/2, L/2] است
- an ضریب سری برای n-th term است
- bn ضریب سری برای n-th term است
- L طول بازه زمانی است
- n یک عدد صحیح مثبت است
- x یک متغیر واقعی است
- pi (pi) یک ثابت ریاضی است
برای یافتن ضرایب سری، باید f(x) را در بازه زمانی [(-L/2, L/2] با استفاده از فرمول های زیر تجزیه کنیم:
an = (1/L) * int(-L/2, L/2) f(x) * cos(n*pi*x/L) dx
bn = (1/L) * int(-L/2, L/2) f(x) * sin(n*pi*x/L) dx
که در آن:
- int نشان دهنده انتگرال است
- L طول بازه زمانی است
- n یک عدد صحیح مثبت است
- x یک متغیر واقعی است
- f(x) تابع پیوسته و متناوب در بازه زمانی [(-L/2, L/2] است
- pi (pi) یک ثابت ریاضی است
پس از یافتن ضرایب سری، می توان از فرمول سری فوریه برای نمایش f(x) در بازه زمانی [(-L/2, L/2] استفاده کرد.<eos>
Esmaeil Zahedi, Mohsen Yazdinejad