Instructions to use haijian06/Yi-1.5-6B-Chat-Math with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use haijian06/Yi-1.5-6B-Chat-Math with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="haijian06/Yi-1.5-6B-Chat-Math") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math") model = AutoModelForCausalLM.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use haijian06/Yi-1.5-6B-Chat-Math with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "haijian06/Yi-1.5-6B-Chat-Math" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "haijian06/Yi-1.5-6B-Chat-Math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/haijian06/Yi-1.5-6B-Chat-Math
- SGLang
How to use haijian06/Yi-1.5-6B-Chat-Math 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 "haijian06/Yi-1.5-6B-Chat-Math" \ --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": "haijian06/Yi-1.5-6B-Chat-Math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "haijian06/Yi-1.5-6B-Chat-Math" \ --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": "haijian06/Yi-1.5-6B-Chat-Math", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use haijian06/Yi-1.5-6B-Chat-Math with Docker Model Runner:
docker model run hf.co/haijian06/Yi-1.5-6B-Chat-Math
Yi-1.5-6B-Chat-Math
Yi-1.5-6B-Chat-Math is a specialized natural language processing model fine-tuned from Yi-1.5 to excel in mathematical problem-solving and related tasks. Designed to handle a wide range of mathematical queries, from algebra and geometry to calculus and beyond, this model serves as a powerful tool for students, educators, and researchers alike.
Features
- Mathematical Problem Solving: Accurately solves various types of mathematical problems, including but not limited to algebra, geometry, and calculus.
- Formula Derivation: Assists in deriving and explaining mathematical formulas to enhance understanding of complex concepts.
- Multilingual Support: Capable of handling mathematical queries in multiple languages, enhancing accessibility for a diverse user base.
- Custom Fine-Tuning: Trained on a proprietary dataset to ensure high performance and reliability in mathematical contexts.
Dataset
The model has been fine-tuned using a custom dataset tailored for advanced mathematical tasks. The dataset is openly available for research and development purposes.
- Dataset Name: Advanced-Math
- Access Link: Advanced-Math Dataset
Installation
To get started with Yi-1.5-6B-Chat-Math, ensure you have the necessary dependencies installed:
pip install transformers torch
Usage
Below is a simple example demonstrating how to use the model for solving a mathematical equation:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math")
model = AutoModelForCausalLM.from_pretrained("haijian06/Yi-1.5-6B-Chat-Math", torch_dtype=torch.float16, device_map="auto")
input_text = "Solve the equation x^2 - 5x + 6 = 0 Let's solve this step-by-step:"
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
do_sample=True,
temperature=0.7,
top_p=0.95,
)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(answer)
Model answer:
Solve the equation x^2 - 5 x + 6 = 0 Let's solve this step-by-step:
Step 1: Factor the equation
The equation can be factored as follows:
x^2 - 5x + 6 = 0
(x - 2)(x - 3) = 0
Step 2: Apply the zero product property
If the product of two numbers is zero, then at least one of the numbers must be zero.
So, either (x - 2) = 0 or (x - 3) = 0
Step 3: Solve for x
If (x - 2) = 0, then x = 2
If (x - 3) = 0, then x = 3
So, the solutions are x = 2 and x = 3.
Answer: 2, 3
Contributing
Contributions are welcome! Whether you have suggestions for improvements, bug reports, or want to contribute code, feel free to open an issue or submit a pull request on GitHub.
License
This project is licensed under the Apache-2.0 License.
Contact
For more information, support, or inquiries, please visit my GitHub profile:
- GitHub: https://github.com/Haijian06
- Downloads last month
- 2