Text Generation
Transformers
Safetensors
PyTorch
English
llama
python
java
cpp
sql
function calling
unit tests
causalLM
codeLLAMA modified archi
document
code
code2doc
instruction_tuned
basemodel
docstring
documentation
text-generation-inference
plan
planner
conversational
Instructions to use PipableAI/pip-code-bandit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use PipableAI/pip-code-bandit with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="PipableAI/pip-code-bandit") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-code-bandit") model = AutoModelForCausalLM.from_pretrained("PipableAI/pip-code-bandit", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use PipableAI/pip-code-bandit with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "PipableAI/pip-code-bandit" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "PipableAI/pip-code-bandit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/PipableAI/pip-code-bandit
- SGLang
How to use PipableAI/pip-code-bandit 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 "PipableAI/pip-code-bandit" \ --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": "PipableAI/pip-code-bandit", "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 "PipableAI/pip-code-bandit" \ --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": "PipableAI/pip-code-bandit", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use PipableAI/pip-code-bandit with Docker Model Runner:
docker model run hf.co/PipableAI/pip-code-bandit
| language: | |
| - en | |
| license: apache-2.0 | |
| library_name: transformers | |
| tags: | |
| - python | |
| - java | |
| - cpp | |
| - sql | |
| - function calling | |
| - unit tests | |
| - causalLM | |
| - codeLLAMA modified archi | |
| - document | |
| - code | |
| - code2doc | |
| - instruction_tuned | |
| - basemodel | |
| - pytorch | |
| - docstring | |
| - documentation | |
| - text-generation-inference | |
| - plan | |
| - planner | |
| metrics: | |
| - accuracy | |
| pipeline_tag: text-generation | |
| widget: | |
| - text: '<example_response>--code:def function_divide2(x): return x / 2--question:Document | |
| the code--doc:Description:This function takes a number and divides it by 2.Parameters:- | |
| x (numeric): The input value to be divided by 2.Returns:- float: The result of | |
| x divided by 2.Example:To call the function, use the following code:function_divide2(1.0)</example_response><function_code>def | |
| _plot_bounding_polygon(polygons_coordinates, output_html_path=bounding_polygon_map.html):map_center | |
| = [sum([coord[0]for polygon_coords in polygons_coordinatesfor coord in polygon_coords])/ | |
| sum([len(polygon_coords) for polygon_coords in polygons_coordinates]),sum([coord[1]for | |
| polygon_coords in polygons_coordinatesfor coord in polygon_coords])/ sum([len(polygon_coords) | |
| for polygon_coords in polygons_coordinates]),]my_map = folium.Map(location=map_center, | |
| zoom_start=12)for polygon_coords in polygons_coordinates:folium.Polygon(locations=polygon_coords,color=blue,fill=True,fill_color=blue,fill_opacity=0.2,).add_to(my_map)marker_cluster | |
| = MarkerCluster().add_to(my_map)for polygon_coords in polygons_coordinates:for | |
| coord in polygon_coords:folium.Marker(location=[coord[0], coord[1]], popup=fCoordinates: | |
| {coord}).add_to(marker_cluster)draw = Draw(export=True)draw.add_to(my_map)my_map.save(output_html_path)return | |
| output_html_path</function_code><question>Document the python code above giving | |
| function description ,parameters and return type and example how to call the function</question><doc>' | |
| example_title: example | |
| # pip-code-bandit | |
| [PipableAI](https://www.pipable.ai/) | |
| [colab_notebook](https://colab.research.google.com/drive/10av3SxFf0Psx_IkmZbcUhiVznStV5pVS?usp=sharing) | |
| [pipflow](https://github.com/PipableAI/pipflow) | |
| [linkedin_post](https://www.linkedin.com/posts/pipable%2Eai_releasing-strategy-activity-7195750109886783489-tHrz?utm_source=share&utm_medium=member_desktop) | |
| [reddit_post](https://www.reddit.com/r/LocalLLaMA/comments/1cqxdl9/unveiling_pipcodebandit_empowering_ai_in_agentic/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button) | |
| ## Objective | |
|  | |
| Given a goal and tools, can AI intelligently use the tools to reach the goal?\ | |
| What if it has a meagre 1.3b params/neurons akin to that of an owl? Can it follow instructions and plan to reach a goal?\ | |
| It can!\ | |
| Releasing **pip-code-bandit** and **pipflow**\ | |
| A `model` and a `library` to manage and run goal-oriented agentic system. | |
| ## Model attributes | |
| ```javascript | |
| -- number of params ~ 1.3b [2.9 Gb GPU memory footprint] | |
| -- sequence length ~ 16.3k [Can go higher but will show performance degradation] | |
| -- license - apache 2.0 | |
| -- instruction following , RL tuned. | |
| -- tasks: | |
| 1. complex planning(plan) of sequential function calls | a list of callables and goal | |
| 2. corrected plan | feedback instructions with error | |
| 3. function calling | doc or code and goal | |
| 4. code generation | plan and goal | |
| 5. code generation | goal | |
| 6. doc generation | code | |
| 7. code generation | doc | |
| 8. file parsed to json | any raw data | |
| 9. sql generation | schema, question, instructions and examples | |
| ``` | |
| ## How did we build it? | |
| We used a simulator to simulate environments where the model could play games to achieve goals, given a set of actions available to it. | |
| All the model could do was find the right action and config to incur a positive reward. | |
| The reward policy is around the concept of a model going to a stable state of zero net sum reward for both good and bad behaviour. | |
| In this setup, the model, which was pre-trained on code, function documentation, and similar OS datasets, was RL-tuned for reliability and instruction-following. | |
| ## License | |
| ```bash | |
| complete open-sourced - apache 2.0. License | |
| ``` | |
| ## Usage | |
| ### NOTE: | |
| If you wish to try this model without utilizing your GPU, we have hosted the model on our end. To execute the library using the hosted model, initialize the generator as shown below: | |
| ```bash | |
| pip3 install git+https://github.com/PipableAI/pipflow.git | |
| ``` | |
| ```python | |
| from pipflow import PipFlow | |
| generator = PipFlow() | |
| ``` | |
| We have hosted the model at https://playground.pipable.ai/infer. Hence, one can also make a POST request to this endpoint with the following payload: | |
| ```json | |
| { | |
| "model_name": "PipableAI/pip-code-bandit", | |
| "prompt": "prompt", | |
| "max_new_tokens": "400" | |
| } | |
| ``` | |
| ```bash | |
| curl -X 'POST' \ | |
| 'https://playground.pipable.ai/infer' \ | |
| -H 'accept: application/json' \ | |
| -H 'Content-Type: application/x-www-form-urlencoded' \ | |
| -d 'model_name=PipableAI%2Fpip-code-bandit&prompt="YOUR PROMPT"&max_new_tokens=400' | |
| ``` | |
| Alternatively, you can directly access the UI endpoint at https://playground.pipable.ai/docs#/default/infer_infer_post. | |
| ### Library Usage | |
| To directly use the model's capabilities without putting extra effort into schemas and prompts, try to use [pipflow](https://github.com/PipableAI/pipflow). | |
| For detailed usage, refer to the [colab_notebook](https://colab.research.google.com/drive/10av3SxFf0Psx_IkmZbcUhiVznStV5pVS?usp=sharing) | |
| ### Model Usage | |
| ```bash | |
| pip install transformers accelerate torch | |
| ``` | |
| ```python | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from accelerate import Accelerator | |
| model =AutoModelForCausalLM.from_pretrained("PipableAI/pip-code-bandit",torch_dtype=torch.bfloat16,device_map="auto") | |
| tokenizer = tokenizer = AutoTokenizer.from_pretrained("PipableAI/pip-code-bandit") | |
| new_tokens = 600 | |
| prompt = """ | |
| <question> | |
| Generate a python function for adding two numbers. | |
| </question> | |
| <code> | |
| """ | |
| inputs = tokenizer(prompt, return_tensors="pt").to("cuda") | |
| outputs = model.generate(**inputs, max_new_tokens=new_tokens) | |
| response = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
| response = response.split("<code>")[1].split("</code>")[0] | |
| print(response) | |
| ``` | |
| ### Prompt | |
| ```python | |
| prompt = f"""<example_response>{--question , --query}</example_response><function_code>{code}</function_code> | |
| <question>Give one line description of the python code above in natural language.</question> | |
| <doc>""" | |
| prompt = f"""<example_response>{example of some --question: , --query}</example_response><schema>{schema with cols described}</schema> | |
| <question>Write a sql query to ....</question> | |
| <sql>""" | |
| ``` | |
| ### Team | |
| ```doc | |
| Avi Kothari, Gyan Ranjan, Pratham Gupta, Ritvik Aryan Kalra, Soham Acharya | |
| ``` |