Views
No views yet
llama.cppen)Qwen/Qwen2.5-1.5B-Instructtransformers + unsloth + trlQ4_K_M, Q8_0, Q5_K_M, f16)transformers in Pythonbitsandbytes by using! pip install -U bitsandbytes1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name)
8
9# Move model to GPU if available
10device = "cuda" if torch.cuda.is_available() else "cpu"
11model.to(device)
12
13# Example inference
14question = "How do I implement a binary search algorithm in Python?"
15inputs = tokenizer(question, return_tensors="pt").to(device)
16output = model.generate(**inputs, max_length=200)
17
18# Decode response
19print(tokenizer.decode(output[0], skip_special_tokens=True))llama.cppllama.cppbrew install llama.cpp1mkdir -p ~/llama_models && cd ~/llama_models
2wget https://huggingface.co/eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1/resolve/main/q8_0.ggufllama-cli -m ~/llama_models/q8_0.gguf --interactivellama-cli -hf eagle0504/qwen-2_5-1_5b-instruct-using-codealpaca-20k-enhanced-v1:Q8_0llama-cli -m ~/llama_models/q8_0.gguf -p "Explain the differences between breadth-first search and depth-first search."1def count_xml(text: str) -> float:
2 """
3 Calculates a reward based on the occurrence of certain XML tags and subtracts penalties for content after closing tags.
4
5 Args:
6 text (str): The text string to analyze for XML tag consistency.
7
8 Returns:
9 float: Total reward score based on XML tag occurrence and penalties.
10 """
11 count = 0.0
12 if text.count("<think>\n") == 1:
13 count += 0.125
14 if text.count("\n</think>\n") == 1:
15 count += 0.125
16 if text.count("\n<answer>\n") == 1:
17 count += 0.125
18 count -= len(text.split("\n</answer>\n")[-1])*0.001
19 if text.count("\n</answer>") == 1:
20 count += 0.125
21 count -= (len(text.split("\n</answer>")[-1]) - 1)*0.001
22
23 # Ensure `<think>` and `</think>` exist
24 if "<think>" in text and "</think>" in text:
25 count += 1.0 # Higher weight to ensure reasoning consistency
26 else:
27 count -= 1.0 # Penalize if missing
28
29 return count| Condition | Reward |
|---|---|
"<think>\n" appears exactly once | +0.125 |
"\n</think>\n" appears exactly once | +0.125 |
"\n<answer>\n" appears exactly once | +0.125 |
"\n</answer>" appears exactly once | +0.125 |
Both <think> and </think> exist anywhere | +1.0 |
No extra text after "</answer>" | No penalty |
"</answer>":
[
-\left( \text{length of extra text} \times 0.001 \right)
]
If the best case occurs (i.e., no extra content), then:1<think>
2Valid reasoning goes here.
3</think>
4
5<answer>
6Correct final answer here.
7</answer>eagle0504/augmented_codealpaca-20k-using-together-ai-deepseek-v1instruction, response, cot (Chain-of-Thought)transformers + unsloth + trl1e-6bf16 or fp16)81024