Text Generation
Transformers
edge-impulse
rag
retrieval-augmented-generation
faiss
qwen
api
documentation
tinyml
edge-ai
Instructions to use edgeimpulse/edgeimpulse-api-docs-rag with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use edgeimpulse/edgeimpulse-api-docs-rag with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="edgeimpulse/edgeimpulse-api-docs-rag")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("edgeimpulse/edgeimpulse-api-docs-rag", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use edgeimpulse/edgeimpulse-api-docs-rag with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "edgeimpulse/edgeimpulse-api-docs-rag" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "edgeimpulse/edgeimpulse-api-docs-rag", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/edgeimpulse/edgeimpulse-api-docs-rag
- SGLang
How to use edgeimpulse/edgeimpulse-api-docs-rag 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 "edgeimpulse/edgeimpulse-api-docs-rag" \ --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": "edgeimpulse/edgeimpulse-api-docs-rag", "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 "edgeimpulse/edgeimpulse-api-docs-rag" \ --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": "edgeimpulse/edgeimpulse-api-docs-rag", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use edgeimpulse/edgeimpulse-api-docs-rag with Docker Model Runner:
docker model run hf.co/edgeimpulse/edgeimpulse-api-docs-rag
File size: 2,035 Bytes
4de1825 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | """Minimal HTTP server for the Edge Impulse docs RAG assistant.
python serve.py --host 0.0.0.0 --port 8000
POST /ask {"question": "...", "k": 4} -> {"answer": "..."}
GET /health -> {"ok": true}
"""
from __future__ import annotations
import argparse
from pathlib import Path
from flask import Flask, jsonify, request
from rag import DEFAULT_API_BASE, DEFAULT_INDEX_DIR, DEFAULT_MODEL, ask
def create_app(index_dir: Path, api_base: str, model: str, k: int) -> Flask:
app = Flask(__name__)
@app.get("/health")
def health():
return jsonify({"ok": True})
@app.post("/ask")
def ask_route():
payload = request.get_json(silent=True) or {}
question = str(payload.get("question", "")).strip()
if not question:
return jsonify({"error": "question is required"}), 400
try:
answer = ask(
question,
index_dir=index_dir,
k=int(payload.get("k", k)),
max_new_tokens=int(payload.get("max_new_tokens", 320)),
api_base=api_base,
model=model,
)
return jsonify({"answer": answer})
except Exception as exc: # noqa: BLE001 - surface the error to the client
return jsonify({"error": str(exc)}), 500
return app
def main() -> None:
parser = argparse.ArgumentParser(description="Serve the Edge Impulse docs RAG assistant.")
parser.add_argument("--host", default="127.0.0.1")
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--index-dir", type=Path, default=DEFAULT_INDEX_DIR)
parser.add_argument("--api-base", default=DEFAULT_API_BASE)
parser.add_argument("--model", default=DEFAULT_MODEL)
parser.add_argument("--k", type=int, default=4)
args = parser.parse_args()
app = create_app(args.index_dir, args.api_base, args.model, args.k)
app.run(host=args.host, port=args.port)
if __name__ == "__main__":
main()
|