Instructions to use Corianas/llama-tiny-reactor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Corianas/llama-tiny-reactor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Corianas/llama-tiny-reactor")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Corianas/llama-tiny-reactor") model = AutoModelForCausalLM.from_pretrained("Corianas/llama-tiny-reactor") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Corianas/llama-tiny-reactor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Corianas/llama-tiny-reactor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Corianas/llama-tiny-reactor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Corianas/llama-tiny-reactor
- SGLang
How to use Corianas/llama-tiny-reactor 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 "Corianas/llama-tiny-reactor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Corianas/llama-tiny-reactor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Corianas/llama-tiny-reactor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Corianas/llama-tiny-reactor", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Corianas/llama-tiny-reactor with Docker Model Runner:
docker model run hf.co/Corianas/llama-tiny-reactor
This is a Re-act style model trained from TinyLlama/TinyLlama_v1.1
Dataset was parsed with:
def extract_trajectory_info(data):
"""
Extracts the question, thoughts, actions, and observations from the trajectory field of the data.
Parameters:
data (dict): The data entry containing the trajectory field.
Returns:
dict: A dictionary containing the extracted question, thoughts, actions, and observations.
"""
# Extracting the question
question = data.get('question', '')
# Extracting thoughts, actions, and observations using regex
thoughts = re.findall(r'Thought \d+: (.+?)(?=Action|\Z)', data.get('trajectory', ''), re.DOTALL)
actions = re.findall(r'Action \d+: (.+?)(?=Observation|\Z)', data.get('trajectory', ''), re.DOTALL)
observations = re.findall(r'Observation \d+: (.+?)(?=Thought|\Z)', data.get('trajectory', ''), re.DOTALL)
# Cleaning up the extracted data
thoughts = [thought.strip() for thought in thoughts]
actions = [action.strip() for action in actions]
observations = [observation.strip() for observation in observations]
return {
'question': question,
'thoughts': thoughts,
'actions': actions,
'observations': observations
}
# Sample data
extracted_info = extract_trajectory_info(ds["train"][0])
Then remade into a new dataset with
# Predefine the instructions for the task
preamble = """Tools available:
(1) Search[entity], which searches the exact entity on Wikipedia and returns the first paragraph if it exists. If not, it will return some similar entities to search.
(2) Lookup[keyword], which returns the next sentence containing the keyword in the current passage.
(3) Finish[answer], which returns the answer and finishes the task.
"""
dataset = []
# Iterate through a specified number of examples in the training set
for i in range(len(ds['train'])):
extracted_info = extract_trajectory_info(ds['train'][i])
# Iterate through each thought in the extracted information
for j in range(len(extracted_info['thoughts'])):
out = f"{preamble}---\nQuestion: {extracted_info['question']}\n"
prev = ""
# Construct output for the first thought
if j == 0:
out += f"Thought: {extracted_info['thoughts'][0]}\n"
out += f"Action: {extracted_info['actions'][0]}\nPAUSE\n\n\n\n"
else:
for k in range(1, j + 1):
# Use appropriate indexing to avoid out-of-bounds errors
prev += f"Thought:{extracted_info['thoughts'][j - k]}\n"
prev += f"Action: {extracted_info['actions'][j - k]}\nPAUSE\n"
prev += f"Observation: {extracted_info['observations'][j - k]}\n"
out += prev # Remove trailing space
out += f"---\nThought: {extracted_info['thoughts'][j]}\n"
out += f"Action: {extracted_info['actions'][j]}\nPAUSE\n\n\n\n"
# Print the constructed output
print(out)
dataset.append(out)
#print(len(out))
- Downloads last month
- 4