Instructions to use tiny-random/internlm2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/internlm2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tiny-random/internlm2", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("tiny-random/internlm2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/internlm2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/internlm2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/internlm2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tiny-random/internlm2
- SGLang
How to use tiny-random/internlm2 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 "tiny-random/internlm2" \ --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": "tiny-random/internlm2", "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 "tiny-random/internlm2" \ --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": "tiny-random/internlm2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tiny-random/internlm2 with Docker Model Runner:
docker model run hf.co/tiny-random/internlm2
This is a randomly initialized tiny model based on internlm/internlm2-chat-20b for testing and debugging.
| Feature | Source | This repo |
|---|---|---|
| Checkpoint tensor elements | 19.86B BF16 | 12.65M BF16 |
| Safetensors weight files | 39.72 GB (21 files) | 25.30 MB (model.safetensors) |
| Layers | 48 | 4 |
| Hidden width / MLP width | 6,144 / 16,384 (2.67x) | 128 / 352 (2.75x) |
| Q heads / KV heads / head_dim | 48 / 8 (GQA 6:1) / 128 | 4 / 4 (MHA) / 32 |
| RoPE base / biases | 1,000,000 / none | Same |
| Vocabulary rows / embedding tying | 92,544 checkpoint / 92,550 tokenizer / untied (source) | 92,550 / tied |
| Stored precision | BF16 | Same |
This InternLM2 revision is not registered in the installed Transformers release, so the pinned upstream remote code is included (load with trust_remote_code=True). The untied tiny checkpoint ties the language-model head to the token embedding (the source shipped them untied), keeping the artifact at 25.30MB within the 30MB best-effort target; the source 6:1 GQA ratio cannot fit four TP=4-legal heads.
| File path | Size |
|---|---|
| model.safetensors | 25.3MB |
Example usage
Transformers (β verified)
Load the included pinned InternLM2 implementation with trust_remote_code=True.
def run_transformers(model_id: str):
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = str(model_id)
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = (
AutoModelForCausalLM.from_pretrained(
model_id, trust_remote_code=True, dtype=torch.bfloat16, attn_implementation="eager"
)
.eval()
.cuda()
)
prompt = tokenizer.apply_chat_template(
[{"role": "user", "content": "δ½ ε₯½οΌθ―·δ»η»δΈδΈδ½ θͺε·±γ"}],
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
assert torch.isfinite(model(**inputs).logits).all()
output = model.generate(**inputs, do_sample=False, max_new_tokens=8)
print(tokenizer.decode(output[0], skip_special_tokens=True))
if __name__ == "__main__":
run_transformers(model_id="tiny-random/internlm2")
SGLang (β verified)
SGLang 0.5.10 ships a native InternLM2ForCausalLM implementation; serve the tiny checkpoint with tensor parallelism:
sglang serve --model-path tiny-random/internlm2 --tp 4 \
--dtype bfloat16 --context-length 1024 --disable-piecewise-cuda-graph --host 0.0.0.0 --port 30000 \
--trust-remote-code
piecewise prefill CUDA graph capture hits CUBLAS_STATUS_INTERNAL_ERROR in wo, so the command below passes --disable-piecewise-cuda-graph.
Send an OpenAI completion request:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
resp = client.completions.create(
model="tiny-random/internlm2", prompt="The quick brown fox", max_tokens=8, temperature=0
)
print(resp.choices[0].text)
Creating this repo
- Code: .meta/create_model.py
- Model structure: .meta/model.log
- Environment: .meta/env.json
Change log
- 2026-11-07: Initial version rebuilt from the official internlm/internlm2-chat-20b source, shipping its pinned remote code.
This repo is generated by GPT-6.1-Sol.
- Downloads last month
- 149
Model tree for tiny-random/internlm2
Base model
internlm/internlm2-chat-20b
Install from pip and serve model
# Install vLLM from pip: pip install vllm# Start the vLLM server: vllm serve "tiny-random/internlm2"# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/internlm2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'