NickyNicky/ngxson_MiniThinky_v1_deduplicated_11_percent
Viewer • Updated • 11.8k • 24 • 3
How to use NickyNicky/Llama-1B-base-GRPO-miniThinky_v1 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="NickyNicky/Llama-1B-base-GRPO-miniThinky_v1")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("NickyNicky/Llama-1B-base-GRPO-miniThinky_v1")
model = AutoModelForCausalLM.from_pretrained("NickyNicky/Llama-1B-base-GRPO-miniThinky_v1")
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 NickyNicky/Llama-1B-base-GRPO-miniThinky_v1 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/NickyNicky/Llama-1B-base-GRPO-miniThinky_v1
How to use NickyNicky/Llama-1B-base-GRPO-miniThinky_v1 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1" \
--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": "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1",
"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 "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1" \
--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": "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use NickyNicky/Llama-1B-base-GRPO-miniThinky_v1 with Docker Model Runner:
docker model run hf.co/NickyNicky/Llama-1B-base-GRPO-miniThinky_v1
https://gist.github.com/willccbb/4676755236bb08cab5f4e54a0475d6fb
I have taken the script from the user 'willccbb' and I have modified it many things to be able to train it.
thanks to this script I already understand many things.
https://colab.research.google.com/drive/1hdWSImb9lJ7Q4Csh3ubLAblhD0EscDPh?usp=sharing
import torch,gc
import transformers
from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, BitsAndBytesConfig
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig,
HfArgumentParser,
TrainingArguments,
pipeline,
logging,
GenerationConfig,
TextIteratorStreamer,
)
from transformers import StoppingCriteria, StoppingCriteriaList
model_name= "NickyNicky/Llama-1B-base-GRPO-miniThinky_v1"
base_model = AutoModelForCausalLM.from_pretrained(model_name,
# quantization_config=bnb_config,
device_map={"":0},
# token=hf_token,
# attn_implementation="flash_attention_2",
torch_dtype=torch.bfloat16
)
max_seq_length=4048
base_tokenizer_0 = AutoTokenizer.from_pretrained(model_name,
# token=access_token,
max_length=max_seq_length)
prompt = "What do you mean by 'core' when referring to a subject or topic?"
sys="""Respond in the following format:
<reasoning>
...
</reasoning>
<answer>
...
</answer>
"""
messages = [
{"role": "system", "content": sys},
{"role": "user", "content": prompt}
]
device = "cuda" # the device to load the model onto
text = base_tokenizer_0.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = base_tokenizer_0([text], return_tensors="pt").to(device)
generated_ids = base_model.generate(
model_inputs.input_ids,
max_new_tokens=1200,
pad_token_id= base_tokenizer_0.eos_token_id,
)
generated_ids = [
output_ids[:] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = base_tokenizer_0.batch_decode(generated_ids, skip_special_tokens=True)[0]
messages.append({"role": "assistant", "content": response})
print(response)
'''
<|begin_of_text|><|begin_of_text|><|start_header_id|>system<|end_header_id|>
Cutting Knowledge Date: December 2023
Today Date: 31 Jan 2025
Respond in the following format:
<reasoning>
...
</reasoning>
<answer>
...
</answer><|eot_id|><|start_header_id|>user<|end_header_id|>
What do you mean by 'core' when referring to a subject or topic?<|eot_id|><|start_header_id|>assistant<|end_header_id|>
<reasoning>
When referring to a "core" in a scientific context, it typically refers to the central, innermost part of the brain or central nervous system, which houses the brain's main processing centers, including the cerebrum, the hippocampus, and the amygdala. The core is involved in controlling and coordinating the body's functions, such as the regulation of the heart rate, blood pressure, and digestion, as well as the processing of sensory information from the environment.
In a more general sense, a core can also refer to the central part of the brain, which is the main processing center of the brain, often containing the brain's main neurons and is involved in the processing of complex information, including the integration of sensory data from the environment, the interpretation of emotions, and the generation of the body's response to the environment.
The core is also often used to describe the central nervous system's main processing centers, which are located in the brain and are responsible for controlling the body's functions, including the regulation of the body's internal and external environment, the processing of the senses, and the generation of the body's response to the environment.
</reasoning>
<answer>
The core is a central part of the brain that plays a vital role in controlling and coordinating the body's functions, and it is involved in the processing of complex information from the environment, the interpretation of emotions, and the generation of the body's response to the environment. It is a central processing center of the brain, and its functions are often compared to the functions of the heart, which is often referred to as the "heart of the brain." The core is also a key component of the brain's main processing centers, which are located in the cerebrum, the hippocampus, and the amygdala.
</answer>
<|eot_id|>
'''
Base model
meta-llama/Llama-3.2-1B-Instruct