Instructions to use botbottingbot/Modular_Intelligence with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use botbottingbot/Modular_Intelligence with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="botbottingbot/Modular_Intelligence")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("botbottingbot/Modular_Intelligence", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use botbottingbot/Modular_Intelligence with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "botbottingbot/Modular_Intelligence" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "botbottingbot/Modular_Intelligence", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/botbottingbot/Modular_Intelligence
- SGLang
How to use botbottingbot/Modular_Intelligence 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 "botbottingbot/Modular_Intelligence" \ --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": "botbottingbot/Modular_Intelligence", "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 "botbottingbot/Modular_Intelligence" \ --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": "botbottingbot/Modular_Intelligence", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use botbottingbot/Modular_Intelligence with Docker Model Runner:
docker model run hf.co/botbottingbot/Modular_Intelligence
Download App.py from botbottingbot/Modular_Intelligence: direct link, hf CLI and curl.
- Browser
- Download file 3.57 kB
-
https://huggingface.co/botbottingbot/Modular_Intelligence/resolve/508deab91f41cbb3507ff47245fa83a91c04be07/App.py
- Command line
-
hf download hf://botbottingbot/Modular_Intelligence@508deab91f41cbb3507ff47245fa83a91c04be07/App.py
-
curl -L -o App.py https://huggingface.co/botbottingbot/Modular_Intelligence/resolve/508deab91f41cbb3507ff47245fa83a91c04be07/App.py
3.57 kB
| import json | |
| from functools import partial | |
| import gradio as gr | |
| from transformers import pipeline | |
| with open("modules.json", "r", encoding="utf-8") as f: | |
| MODULES = json.load(f)["modules"] | |
| GENERATORS = [m for m in MODULES if m["type"] == "generator"] | |
| CHECKERS = {m["id"]: m for m in MODULES if m["type"] == "checker"} | |
| GEN_BY_ID = {m["id"]: m for m in GENERATORS} | |
| llm = pipeline("text-generation", model="gpt2", max_new_tokens=512) | |
| def call_llm(prompt): | |
| out = llm(prompt, max_new_tokens=512, do_sample=False)[0]["generated_text"] | |
| return out[len(prompt):].strip() if out.startswith(prompt) else out | |
| def generator_prompt(module_id, *inputs): | |
| m = GEN_BY_ID[module_id] | |
| keys = list(m["input_placeholders"].keys()) | |
| inputs = {k: inputs[i] if i < len(inputs) else "" for i, k in enumerate(keys)} | |
| sections = m["output_sections"] | |
| p = [] | |
| p.append("You are a structured reasoning module.") | |
| p.append(f"MODULE: {m['label']}") | |
| p.append("INPUTS:") | |
| for k, v in inputs.items(): | |
| p.append(f"{k.upper()}: {v}") | |
| p.append("") | |
| p.append("Produce the following sections:") | |
| for s in sections: | |
| p.append(f"- {s}") | |
| p.append("") | |
| for s in sections: | |
| p.append(f"{s}:") | |
| p.append("[content]") | |
| p.append("") | |
| return "\n".join(p) | |
| def checker_prompt(checker_id, *vals): | |
| c = CHECKERS[checker_id] | |
| secs = c["output_sections"] | |
| if len(vals) == 0: | |
| orig, draft = "", "" | |
| elif len(vals) == 1: | |
| orig, draft = "", vals[0] | |
| else: | |
| *orig_parts, draft = vals | |
| orig = "\n\n".join(orig_parts) | |
| p = [] | |
| p.append("You are a strict evaluator.") | |
| p.append(f"CHECKER: {c['label']}") | |
| p.append("ORIGINAL TASK:") | |
| p.append(orig) | |
| p.append("") | |
| p.append("DRAFT OUTPUT:") | |
| p.append(draft) | |
| p.append("") | |
| p.append("Respond with sections:") | |
| for s in secs: | |
| p.append(f"- {s}") | |
| p.append("") | |
| for s in secs: | |
| p.append(f"{s}:") | |
| p.append("[content]") | |
| p.append("") | |
| return "\n".join(p) | |
| def run_generator(mid, *inputs): | |
| return call_llm(generator_prompt(mid, *inputs)) | |
| def run_checker(cid, *inputs): | |
| return call_llm(checker_prompt(cid, *inputs)) | |
| def build_ui(): | |
| with gr.Blocks(title="Modular Intelligence") as demo: | |
| gr.Markdown("# Modular Intelligence\nSelect a module and generate output.") | |
| for m in GENERATORS: | |
| with gr.Tab(m["label"]): | |
| gr.Markdown(m["description"]) | |
| input_boxes = [] | |
| for key, ph in m["input_placeholders"].items(): | |
| tb = gr.Textbox(label=key, placeholder=ph, lines=4) | |
| input_boxes.append(tb) | |
| output_box = gr.Textbox(label="Module output", lines=18) | |
| gr.Button("Run module").click( | |
| fn=partial(run_generator, m["id"]), | |
| inputs=input_boxes, | |
| outputs=output_box | |
| ) | |
| if m.get("has_checker"): | |
| cid = m.get("checker_id") | |
| if cid in CHECKERS: | |
| gr.Markdown("### Checker") | |
| checker_out = gr.Textbox(label="Checker output", lines=14) | |
| gr.Button("Run checker").click( | |
| fn=partial(run_checker, cid), | |
| inputs=input_boxes + [output_box], | |
| outputs=checker_out | |
| ) | |
| return demo | |
| if __name__ == "__main__": | |
| app = build_ui() | |
| app.launch() |