Text Generation
Transformers
Safetensors
English
phi3
conversational
custom_code
text-generation-inference
Instructions to use Gigax/NPC-LLM-3_8B-128k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Gigax/NPC-LLM-3_8B-128k with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Gigax/NPC-LLM-3_8B-128k", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Gigax/NPC-LLM-3_8B-128k", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Gigax/NPC-LLM-3_8B-128k", trust_remote_code=True) 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 Gigax/NPC-LLM-3_8B-128k with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Gigax/NPC-LLM-3_8B-128k" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Gigax/NPC-LLM-3_8B-128k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Gigax/NPC-LLM-3_8B-128k
- SGLang
How to use Gigax/NPC-LLM-3_8B-128k 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 "Gigax/NPC-LLM-3_8B-128k" \ --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": "Gigax/NPC-LLM-3_8B-128k", "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 "Gigax/NPC-LLM-3_8B-128k" \ --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": "Gigax/NPC-LLM-3_8B-128k", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Gigax/NPC-LLM-3_8B-128k with Docker Model Runner:
docker model run hf.co/Gigax/NPC-LLM-3_8B-128k
NPC Model
This repo contains the domain-specific NPC model we've fined-tuned from Phi-3-128k, using LoRA.
This model parses a text description of a game scene, and outputs commands like:
say <player1> "Hello Adventurer, care to join me on a quest?greet <player1>attack <player1>- Any other
<action> <param>you add to the prompt! (We call these "skills"!)
โ ๏ธ This model has been trained to overfit on our input prompt format. Follow it closely to reach optimal performance โ ๏ธ
Usage
Make your life easier, use our Python client library
- Instantiating the model using outlines:
from outlines import models
from gigax.step import NPCStepper
# Download model from the Hub
model_name = "Gigax/NPC-LLM-3_8B-128k"
llm = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Our stepper takes in a Outlines model to enable guided generation
# This forces the model to follow our output format
model = models.Transformers(llm, tokenizer)
# Instantiate a stepper: handles prompting + output parsing
stepper = NPCStepper(model=model)
- Calling the model on your game's data:
from gigax.parse import CharacterAction
from gigax.scene import (
Character,
Item,
Location,
ProtagonistCharacter,
ProtagonistCharacter,
Skill,
ParameterType,
)
# Use sample data
context = "Medieval world"
current_location = Location(name="Old Town", description="A quiet and peaceful town.")
locations = [current_location] # you can add more locations to the scene
NPCs = [
Character(
name="John the Brave",
description="A fearless warrior",
current_location=current_location,
)
]
protagonist = ProtagonistCharacter(
name="Aldren",
description="Brave and curious",
current_location=current_location,
memories=["Saved the village", "Lost a friend"],
quests=["Find the ancient artifact", "Defeat the evil warlock"],
skills=[
Skill(
name="Attack",
description="Deliver a powerful blow",
parameter_types=[ParameterType.character],
)
],
psychological_profile="Determined and compassionate",
)
items = [Item(name="Sword", description="A sharp blade")]
events = [
CharacterAction(
command="Say",
protagonist=protagonist,
parameters=[items[0], "What a fine sword!"],
)
]
action = stepper.get_action(
context=context,
locations=locations,
NPCs=NPCs,
protagonist=protagonist,
items=items,
events=events,
)
Input prompt
Here's a sample input prompt, showing you the format on which the model has been trained:
- WORLD KNOWLEDGE: A vast open world full of mystery and adventure.
- KNOWN LOCATIONS: Old Town
- NPCS: John the Brave
- CURRENT LOCATION: Old Town: A quiet and peaceful town.
- CURRENT LOCATION ITEMS: Sword
- LAST EVENTS:
Aldren: Say Sword What a fine sword!
- PROTAGONIST NAME: Aldren
- PROTAGONIST PSYCHOLOGICAL PROFILE: Brave and curious
- PROTAGONIST MEMORIES:
Saved the village
Lost a friend
- PROTAGONIST PENDING QUESTS:
Find the ancient artifact
Defeat the evil warlock
- PROTAGONIST ALLOWED ACTIONS:
Attack <character> : Deliver a powerful blow
Aldren:
๐ค We are currently working hard on training on the latest SoTA models (Phi-3, LLama, etc.), and on better data ! ๐ค
Model info
- Developed by: Gigax
- Language(s) (NLP): English
- Finetuned from model [optional]: Phi-3-mini-128k-instruct
- Contact: Join our Discord for info, help, and more!
How to Cite
@misc{NPC-LLM-3_8B-128k,
url={[https://huggingface.co/Gigax/NPC-LLM-3_8B-128k](https://huggingface.co/Gigax/NPC-LLM-3_8B-128k)},
title={NPC-LLM-3_8B-128k},
author={Gigax team}
}
- Downloads last month
- 14