Instructions to use tangledgroup/tangled-alpha-0.7-core with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tangledgroup/tangled-alpha-0.7-core with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tangledgroup/tangled-alpha-0.7-core")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tangledgroup/tangled-alpha-0.7-core") model = AutoModelForCausalLM.from_pretrained("tangledgroup/tangled-alpha-0.7-core", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tangledgroup/tangled-alpha-0.7-core with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tangledgroup/tangled-alpha-0.7-core" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tangledgroup/tangled-alpha-0.7-core", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tangledgroup/tangled-alpha-0.7-core
- SGLang
How to use tangledgroup/tangled-alpha-0.7-core 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 "tangledgroup/tangled-alpha-0.7-core" \ --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": "tangledgroup/tangled-alpha-0.7-core", "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 "tangledgroup/tangled-alpha-0.7-core" \ --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": "tangledgroup/tangled-alpha-0.7-core", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tangledgroup/tangled-alpha-0.7-core with Docker Model Runner:
docker model run hf.co/tangledgroup/tangled-alpha-0.7-core
| from functools import partial | |
| from transformers import AutoTokenizer | |
| from litgpt.tokenizer import Tokenizer | |
| from litdata import optimize, TokensLoader, StreamingDataset | |
| from utils import tokenize_fn | |
| from core_base_datasets import core_base_datasets | |
| from core_instruct_datasets import core_instruct_datasets | |
| tokenizer_path = '../tokenizer' | |
| seqs = [ | |
| (0, 1073741824, 4097, 4000), | |
| ] | |
| # | |
| # optimize datasets | |
| # | |
| for i, (min_len, max_len, block_size, subchunk_size) in enumerate(seqs): | |
| chunk_size = block_size * subchunk_size | |
| output_dir = f'../core-data-{i}-{min_len}-{max_len}-{block_size}-{subchunk_size}' | |
| outputs = optimize( | |
| fn=partial( | |
| tokenize_fn, | |
| min_len=min_len, | |
| max_len=max_len, | |
| hf_tokenizer=AutoTokenizer.from_pretrained(tokenizer_path, trust_remote_code=True, use_fast=True), | |
| tokenizer=Tokenizer(tokenizer_path), | |
| ), | |
| inputs=core_base_datasets + core_instruct_datasets, | |
| output_dir=output_dir, | |
| chunk_size=chunk_size, # Number of tokens to store by chunks. This is roughly 64MB of tokens per chunk. | |
| num_workers=32, | |
| reorder_files=False, | |
| ## This is important to inform LitData that we are encoding contiguous 1D array (tokens). | |
| ## LitData skips storing metadata for each sample e.g all the tokens are concatenated to form one large tensor. | |
| # item_loader=TokensLoader(block_size=block_size), | |
| ) | |
| # | |
| # total number of chunks in datasets | |
| # | |
| for i, (min_len, max_len, block_size, subchunk_size) in enumerate(seqs): | |
| chunk_size = block_size * subchunk_size | |
| input_dir = f'../core-data-{i}-{min_len}-{max_len}-{block_size}-{subchunk_size}' | |
| dataset = StreamingDataset( | |
| input_dir=input_dir, | |
| item_loader=TokensLoader(block_size=block_size), | |
| ) | |
| print(f'{i=}, {min_len=}, {max_len=}, {block_size=}, {chunk_size=}, {len(dataset)=}, {len(dataset) * block_size=}') | |
| total_tokens = len(dataset) * block_size | |
| print(f'Total number of tokens in the optimized dataset {input_dir!r} is {total_tokens}') | |
| print() | |