Instructions to use nexis-labs/Flock_Web3_Agent_Model-fork with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nexis-labs/Flock_Web3_Agent_Model-fork with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nexis-labs/Flock_Web3_Agent_Model-fork") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("nexis-labs/Flock_Web3_Agent_Model-fork") model = AutoModelForCausalLM.from_pretrained("nexis-labs/Flock_Web3_Agent_Model-fork") 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 Settings
- vLLM
How to use nexis-labs/Flock_Web3_Agent_Model-fork with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nexis-labs/Flock_Web3_Agent_Model-fork" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nexis-labs/Flock_Web3_Agent_Model-fork", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nexis-labs/Flock_Web3_Agent_Model-fork
- SGLang
How to use nexis-labs/Flock_Web3_Agent_Model-fork 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 "nexis-labs/Flock_Web3_Agent_Model-fork" \ --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": "nexis-labs/Flock_Web3_Agent_Model-fork", "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 "nexis-labs/Flock_Web3_Agent_Model-fork" \ --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": "nexis-labs/Flock_Web3_Agent_Model-fork", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nexis-labs/Flock_Web3_Agent_Model-fork with Docker Model Runner:
docker model run hf.co/nexis-labs/Flock_Web3_Agent_Model-fork
Introduction
FLock Web3 Agent Model is a specialized LLM designed to address complex queries in the Web3 ecosystem, with a focus on DeFi, blockchain interoperability, on-chain analytics, and etc.. The model excels in function-calling reasoning, enabling it to break down intricate user requests into actionable steps, interact with external APIs, and provide data-driven insights for Web3 applications. It is tailored for users ranging from developers and researchers to investors navigating the decentralized landscape.
Requirements
We advise you to use the latest version of transformers.
Quickstart
Given a query and a list of available tools. The model generate function calls using the provided tools to respond the query correctly.
Example query and tools format
input_example=
{
"query": "Track crosschain message verification, implement timeout recovery procedures.",
"tools": [
{"type": "function", "function": {"name": "track_crosschain_message", "description": "Track the status of a crosschain message", "parameters": {"type": "object", "properties": {"message_id": {"type": "string"}}}}},
{"type": "function", "function": {"name": "schedule_timeout_check", "description": "Schedule a timeout check for a message", "parameters": {"type": "object", "properties": {"message_id": {"type": "string"}, "timeout": {"type": "integer"}}}}}
]
}
Function calling generation
from transformers import AutoModelForCausalLM, AutoTokenizer
import json
model_name = "flock-io/Flock_Web3_Agent_Model"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
messages = [
{"role": "system", "content": "You are a helpful assistant with access to the following functions. Use them if required -"
+ json.dumps(input_example["tools"], ensure_ascii=False)},
{"role": "user", "content": input_example["query"]}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=3000
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
The output text is in the string format
[
{"name": "track_crosschain_message", "arguments": {"message_id": "msg12345"}},
{"name": "schedule_timeout_check", "arguments": {"message_id": "msg12345", "timeout": "30"}}
]
- Downloads last month
- 3