Views
No views yet
q), key (k), and value (v) projection matrices.| Parameter | Value |
|---|---|
| dataset | HuggingFaceH4/MATH-500 |
| temperature | 0.6 |
| top_p | 0.95 |
| max_new_tokens | 2048 |
| Num_samples | 16 per question |
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "PursuitOfDataScience/Qwen2.5-1.5B-Instruct-Lora-Deepseek-R1"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
8
9test_prompt = "Instruction: Explain how machine learning works\nResponse:"
10inputs = tokenizer(test_prompt, return_tensors="pt").to(model.device)
11
12with torch.no_grad():
13 outputs = model.generate(
14 inputs.input_ids,
15 max_length=200,
16 temperature=0.7,
17 top_p=0.95,
18 do_sample=True
19 )
20
21generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
22print(f"\nGenerated response:\n{generated_text}")
23Instruction: Explain how machine learning works
Response: Machine learning is a subset of artificial intelligence that allows computers to learn from data without being explicitly programmed. It involves using algorithms and statistical models to analyze patterns, trends, or relationships in large sets of data and then making predictions or decisions based on these insights.
Here's an overview of the key steps involved in implementing a machine learning model:
1. Data collection: Gather historical data relevant to your problem domain.
2. Data preprocessing: Cleanse, normalize, and transform raw data into a format suitable for analysis.
3. Feature selection: Identify important features (variables) that can help predict outcomes.
4. Model training: Train various machine learning algorithms on subsets of labeled data.
5. Model evaluation: Assess performance metrics like accuracy, precision, recall, etc., using test datasets.
6. Model tuning: Optimize hyperparameters and tweak algorithm settings to improve predictive power.
7. Deployment: Implement trained models in production systems for real-time predictions.