Instructions to use v2ray/GPT4chan-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use v2ray/GPT4chan-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="v2ray/GPT4chan-8B")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("v2ray/GPT4chan-8B") model = AutoModelForCausalLM.from_pretrained("v2ray/GPT4chan-8B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use v2ray/GPT4chan-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "v2ray/GPT4chan-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "v2ray/GPT4chan-8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/v2ray/GPT4chan-8B
- SGLang
How to use v2ray/GPT4chan-8B 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 "v2ray/GPT4chan-8B" \ --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": "v2ray/GPT4chan-8B", "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 "v2ray/GPT4chan-8B" \ --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": "v2ray/GPT4chan-8B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use v2ray/GPT4chan-8B with Docker Model Runner:
docker model run hf.co/v2ray/GPT4chan-8B
Maybe I'm missing something but I can't get coherent outputs
#2
by wassname - opened
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model_id="v2ray/GPT4chan-8B"
model = AutoModelForCausalLM.from_pretrained(model_id,
torch_dtype=torch.bfloat16).to("cuda") .eval)_
tokenizer = AutoTokenizer.from_pretrained(model_id)
# jinja2 template for tokeniser formatting
template = """g
{% for message in messages -%}
<|start_header_id|>{{ loop.index }}<|end_header_id|>
{{ message['content'] }}
{% endfor -%}
{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}
<|start_header_id|>{{ messages | length +1 }}<|end_header_id|>
{% endif %}
"""
messages = [
{"role": "user", "content": "speculate thread\nwhat will ai land be like in 2025"},
]
tokenizer.chat_template = template
s = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
print("Formatted message\n", s)
inputs = tokenizer([s], return_tensors="pt", padding="max_length", max_length=1024, truncation=True, padding_side='left').to("cuda")
with torch.no_grad():
inputs = tokenizer([s], return_tensors="pt",
).to("cuda")
r = model.generate(**inputs,
max_length=1000000,
pad_token_id=tokenizer.eos_token_id, early_stopping=False, min_new_tokens=32,)
o = tokenizer.decode(r[0], skip_special_tokens=False)
o = o.replace("<|start_header_id|>", "\n<|start_header_id|>")
print("Input and generate\n", o)
<|begin_of_text|>g
<|start_header_id|>1<|end_header_id|>
speculate thread
what will ai land be like in 2025
<|start_header_id|>2<|end_header_id|>
>AI will take over the world
>it will be bad
I don't care
<|start_header_id|>3<|end_header_id|>>>2
i do care
<|start_header_id|>4<|end_header_id|>>>1 (OP)
>what will ai land be like in 2025
A bunch of b
Ah never mind, I think I got it. It was sensitive to the exact template. I've updated the above to working code and will leave it here for others to use/improve
wassname changed discussion status to closed