Text Generation
Transformers
Safetensors
English
gemma
function calling
on-device language model
android
conversational
text-generation-inference
Instructions to use NexaAI/Octopus-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NexaAI/Octopus-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NexaAI/Octopus-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NexaAI/Octopus-v2") model = AutoModelForCausalLM.from_pretrained("NexaAI/Octopus-v2", device_map="auto") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NexaAI/Octopus-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NexaAI/Octopus-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NexaAI/Octopus-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NexaAI/Octopus-v2
- SGLang
How to use NexaAI/Octopus-v2 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 "NexaAI/Octopus-v2" \ --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": "NexaAI/Octopus-v2", "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 "NexaAI/Octopus-v2" \ --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": "NexaAI/Octopus-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NexaAI/Octopus-v2 with Docker Model Runner:
docker model run hf.co/NexaAI/Octopus-v2
| def adjust_volume(volume_diff=None, set_value=None): | |
| """ | |
| Adjusts the device's volume by a specified difference or sets it to a specified value. Only one operation can be performed at a time. | |
| Parameters: | |
| - volume_diff (int, optional): The amount to adjust the current volume by. Positive to increase, negative to decrease, optional to provide. | |
| - set_value (int, optional): The target volume level to set, in the range of 0 to 50, optional to provide. | |
| Note: | |
| - If both `volume_diff` and `set_value` are provided, only one will be considered based on the implementation's logic. | |
| Returns: | |
| - bool: True if the volume was adjusted successfully, False otherwise. | |
| """ | |
| def set_climate_temperature(zone, temperature): | |
| """ | |
| Configures the temperature for a specific zone within the vehicle's climate control system. | |
| Parameters: | |
| - zone (str): The zone to set the temperature for ('driver', 'passenger', 'rear'). | |
| - temperature (int): The target temperature in Fahrenheit, within the range of 60 to 80 degrees. | |
| Returns: | |
| - bool: True if the temperature was set successfully, False otherwise. | |
| """ | |
| def adjust_seat_position(seat, position, distance): | |
| """ | |
| Modifies the position of a specified seat by a certain distance. | |
| Parameters: | |
| - seat (str): The seat identifier ('driver', 'passenger'). | |
| - position (str): The direction to adjust the seat in ('forward', 'backward', 'up', 'down'). | |
| - distance (int): The amount of adjustment in millimeters. | |
| Returns: | |
| - bool: True if the seat was adjusted successfully, False otherwise. | |
| """ | |
| def control_window(window, position, distance): | |
| """ | |
| Adjusts a vehicle window's position by a specific distance. | |
| Parameters: | |
| - window (str): The window to control ('front left', 'front right', 'rear left', 'rear right'). | |
| - position (str): The direction to move the window ('up' or 'down'). | |
| - distance (int): The distance to move the window, in millimeters. | |
| Returns: | |
| - bool: True if the window was adjusted successfully, False otherwise. | |
| """ | |
| def operate_sunroof(action, intensity=None): | |
| """ | |
| Operates the sunroof with a specified action and optional intensity. | |
| Parameters: | |
| - action (str): The sunroof operation to perform ('open', 'close', 'tilt'). | |
| - intensity (int, optional): The degree to which the sunroof should be opened or tilted, as a percentage, optional to provide. | |
| Returns: | |
| - bool: True if the sunroof was operated successfully, False otherwise. | |
| """ | |
| def toggle_interior_lights(light, state): | |
| """ | |
| Changes the state of selected interior lights. | |
| Parameters: | |
| - light (str): The interior light to toggle ('dome', 'reading'). | |
| - state (bool): The desired state of the light (True for on, False for off). | |
| Returns: | |
| - bool: True if the light state was changed successfully, False otherwise. | |
| """ | |
| def activate_seat_heater(seat, level): | |
| """ | |
| Activates the heating feature for a specified seat at a given level. | |
| Parameters: | |
| - seat (str): The seat to activate the heater in ('driver', 'passenger'). | |
| - level (int): The heating intensity level, from 1 to 3. | |
| """ | |
| def adjust_steering_wheel(position, distance): | |
| """ | |
| Adjusts the position of the steering wheel. | |
| Parameters: | |
| - position (str): The direction to adjust the steering wheel ('up', 'down', 'forward', 'backward'). | |
| - distance (int): The distance to adjust the steering wheel, in millimeters. | |
| Returns: | |
| - bool: True if the steering wheel was adjusted successfully, False otherwise. | |
| """ | |
| def set_ambient_lighting(color, brightness): | |
| """ | |
| Configures the ambient lighting of the vehicle. | |
| Parameters: | |
| - color (str): The color setting for the ambient light ('white', 'blue', 'green'). | |
| - brightness (int): The brightness level, from 1 to 5. | |
| Returns: | |
| - bool: True if the ambient lighting was set successfully, False otherwise. | |
| """ | |
| def change_media_source(source): | |
| """ | |
| Switches the current media source to the specified source. | |
| Parameters: | |
| - source (str): The media source to switch to ('radio', 'Bluetooth', 'USB'). | |
| Returns: | |
| - bool: True if the media source was changed successfully, False otherwise. | |
| """ | |
| def navigate_media_tracks(direction): | |
| """ | |
| Navigates through media tracks in the current media source. | |
| Parameters: | |
| - direction (str): The direction to navigate ('next' or 'previous'). | |
| Returns: | |
| - bool: True if the media tracks were navigated successfully, False otherwise. | |
| """ | |
| def set_navigation_destination(destination): | |
| """ | |
| Sets a destination in the vehicle's navigation system. | |
| Parameters: | |
| - destination (str): The address or location to navigate to. | |
| Returns: | |
| - bool: True if the destination was set successfully, False otherwise. | |
| """ | |
| def control_air_flow_direction(zone, direction): | |
| """ | |
| Adjusts the direction of air flow in the climate control system for a specific zone. | |
| Parameters: | |
| - zone (str): The zone to adjust air flow direction ('driver', 'passenger', 'rear'). | |
| - direction (str): The air flow direction ('face', 'feet', 'windshield'). | |
| Returns: | |
| - bool: True if the air flow direction was adjusted successfully, False otherwise. | |
| """ | |
| def toggle_door_locks(door, state): | |
| """ | |
| Changes the lock state of a specific door. | |
| Parameters: | |
| - door (str): The door whose lock state is to be toggled ('front left', 'front right', 'rear left', 'rear right'). | |
| - state (bool): The desired lock state (True to lock, False to unlock). | |
| Returns: | |
| - bool: True if the door lock state was changed successfully, False otherwise. | |
| """ | |
| def adjust_cabin_fragrance(level): | |
| """ | |
| Modifies the intensity of the cabin fragrance system. | |
| Parameters: | |
| - level (int): The fragrance intensity level, from 1 to 5. | |
| Returns: | |
| - bool: True if the fragrance level was adjusted successfully, False otherwise. | |
| """ | |
| def activate_parking_sensors(activate): | |
| """ | |
| Turns the parking sensors on or off. | |
| Parameters: | |
| - activate (bool): True to activate the sensors, False to deactivate them. | |
| Returns: | |
| - bool: True if the parking sensors were activated or deactivated successfully, False otherwise. | |
| """ | |
| def control_infotainment_brightness(level): | |
| """ | |
| Sets the brightness level of the infotainment system display. | |
| Parameters: | |
| - level (int): The desired brightness level, from 1 to 5. | |
| Returns: | |
| - bool: True if the brightness level was set successfully, False otherwise. | |
| """ | |
| def adjust_head_up_display(visibility): | |
| """ | |
| Toggles the visibility of the head-up display (HUD). | |
| Parameters: | |
| - visibility (bool): True to make the HUD visible, False to hide it. | |
| Returns: | |
| - bool: True if the HUD visibility was toggled successfully, False otherwise. | |
| """ | |
| def control_heated_steering_wheel(state): | |
| """ | |
| Activates or deactivates the heated steering wheel. | |
| Parameters: | |
| - state (bool): True to turn the heating on, False to turn it off. | |
| Returns: | |
| - bool: True if the heated steering wheel was activated or deactivated successfully, False otherwise. | |
| """ | |
| def adjust_footwell_lighting(color, brightness): | |
| """ | |
| Customizes the footwell lighting in terms of color and brightness. | |
| Parameters: | |
| - color (str): The color of the footwell lighting ('red', 'green', 'blue', 'white'). | |
| - brightness (int): The brightness level, from 1 to 5. | |
| Returns: | |
| - bool: True if the footwell lighting was adjusted successfully, False otherwise. | |
| """ |