Views
No views yet
llama-cpp-python)app/
main.py # FastAPI app
rag.py # FAISS utilities
ingest.py # build index from public sources
settings.py # config via env
scripts/
download_model.py
Dockerfile
requirements.txt1python3.12 -m venv .venv
2. .venv/bin/activate
3pip install -r requirements.txt
4
5# Download 4-bit Phi-3 GGUF
6python scripts/download_model.py \
7 --repo microsoft/Phi-3-mini-4k-instruct-gguf \
8 --filename Phi-3-mini-4k-instruct-q4.gguf \
9 --out models
10
11# Build FAISS index from public pages
12python -m app.ingest --pages "Large_language_model,Azure,Quantization_(signal_processing)" --lang en
13
14# Run API
15export MODEL_PATH="models/Phi-3-mini-4k-instruct-q4.gguf"
16export N_GPU_LAYERS="-1" # Metal offload on Mac
17uvicorn app.main:app --host 0.0.0.0 --port 80001curl http://localhost:8000/health
2curl -X POST http://localhost:8000/chat \
3 -H "Content-Type: application/json" \
4 -d '{"question":"What is quantization in signal processing?"}'docker build -t quant-llm .1docker run --rm -p 8000:8000 \
2 -e MODEL_PATH=/models/Phi-3-mini-4k-instruct-q4.gguf \
3 -v "$PWD/models:/models" \
4 quant-llm1az group create -n rg-quant-llm -l westeurope
2az acr create -n acrquantllm -g rg-quant-llm --sku Basic
3az acr login -n acrquantllm
4az acr build -t quant-llm:1 -r acrquantllm .1az container create \
2 -g rg-quant-llm \
3 -n quant-llm-api \
4 --image acrquantllm.azurecr.io/quant-llm:1 \
5 --registry-login-server acrquantllm.azurecr.io \
6 --registry-username <ACR_USERNAME> \
7 --registry-password <ACR_PASSWORD> \
8 --cpu 2 --memory 6 \
9 --ports 8000 \
10 --environment-variables MODEL_PATH=/models/Phi-3-mini-4k-instruct-q4.gguf N_THREADS=2 N_GPU_LAYERS=0 \
11 --command-line "bash -lc 'python scripts/download_model.py --repo microsoft/Phi-3-mini-4k-instruct-gguf --filename Phi-3-mini-4k-instruct-q4.gguf --out /models && uvicorn app.main:app --host 0.0.0.0 --port 8000'"az container show -g rg-quant-llm -n quant-llm-api --query ipAddress.ip -o tsvapp/settings.py:MODEL_PATH (default: models/phi-3-mini-4k-instruct-q4.gguf)N_CTX (default: 4096)N_THREADS (default: 8)N_GPU_LAYERS (default: 0, use -1 on Mac for Metal)RAG_TOP_K (default: 4)app/ingest.py to your own docs.CONTRIBUTING.md.LICENSE.