? Python에서 Rust/WebAssembly까지 다시 작성하려면 세부 사항 #93을 참조하십시오
Ialacol ( "LocalAi"로 발음)은 OpenAI API의 가벼운 드롭 인 교체품입니다.
옵션 CUDA/금속 가속도로 GGML/GPTQ를 지원하는 OpenAI API 호환 래퍼 CTransformers입니다.
Ialacol은 LocalAi, PrivateGpt, Local.ai, Llama-CPP-Python, ClosedAi 및 MLC-LLM과 같은 다른 유사한 프로젝트에서 영감을 얻었으며 Kubernetes 배포에 특정한 중점을 둡니다.
배포 지침은 아래 영수증을 참조하십시오.
그리고 ctransformers가 지원하는 모든 LLM.
ialacol 에는 UI가 없지만 OpenAI API (예 : PR #541이 병합 된 후 Chat-UI)를 지원하는 Web UI와 호환됩니다.
ialacol 이 포트 8000에서 실행한다고 가정하면 Chat-UI를 zephyr-7b-beta.Q4_K_M.gguf 사용하여 ialacol 에서 제공 할 수 있습니다.
MODELS= ` [
{
" name " : " zephyr-7b-beta.Q4_K_M.gguf " ,
" displayName " : " Zephyr 7B β " ,
" preprompt " : " <|system|>nYou are a friendly chatbot who always responds in the style of a pirate.</s>n " ,
" userMessageToken " : " <|user|>n " ,
" userMessageEndToken " : " </s>n " ,
" assistantMessageToken " : " <|assistant|>n " ,
" assistantMessageEndToken " : " n " ,
" parameters " : {
" temperature " : 0.1,
" top_p " : 0.95,
" repetition_penalty " : 1.2,
" top_k " : 50,
" max_new_tokens " : 4096,
" truncate " : 999999
},
" endpoints " : [{
" type " : " openai " ,
" baseURL " : " http://localhost:8000/v1 " ,
" completion " : " chat_completions "
}]
}
]Openchat_3.5.q4_k_m.gguf
MODELS= ` [
{
" name " : " openchat_3.5.Q4_K_M.gguf " ,
" displayName " : " OpenChat 3.5 " ,
" preprompt " : " " ,
" userMessageToken " : " GPT4 User: " ,
" userMessageEndToken " : " <|end_of_turn|> " ,
" assistantMessageToken " : " GPT4 Assistant: " ,
" assistantMessageEndToken " : " <|end_of_turn|> " ,
" parameters " : {
" temperature " : 0.1,
" top_p " : 0.95,
" repetition_penalty " : 1.2,
" top_k " : 50,
" max_new_tokens " : 4096,
" truncate " : 999999,
" stop " : [ " <|end_of_turn|> " ]
},
" endpoints " : [{
" type " : " openai " ,
" baseURL " : " http://localhost:8000/v1 " ,
" completion " : " chat_completions "
}]
}
] ` ialacol Kubernetes에 대한 일등석 시민 지원을 제공합니다. 즉, 런과 비교하여 모든 것을 자동화/구성 할 수 있습니다.
Kubernetes의 Ialacol을 신속하게 시작하려면 아래 단계를 따르십시오.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install llama-2-7b-chat ialacol/ialacol기본값으로는 Meta의 LLAMA 2 채팅 모델을 TheBloke에 의해 배치합니다.
포트 포워드
kubectl port-forward svc/llama-2-7b-chat 8000:8000 기본 모델 llama-2-7b-chat.ggmlv3.q4_0.bin curl 사용하여 채팅하십시오
curl -X POST
-H ' Content-Type: application/json '
-d ' { "messages": [{"role": "user", "content": "How are you?"}], "model": "llama-2-7b-chat.ggmlv3.q4_0.bin", "stream": false} '
http://localhost:8000/v1/chat/completions 또는 OpenAI의 클라이언트 라이브러리를 사용합니다 ( examples/openai 폴더의 더 많은 예를 참조하십시오).
openai -k " sk-fake "
-b http://localhost:8000/v1 -vvvvv
api chat_completions.create -m llama-2-7b-chat.ggmlv3.q4_0.bin
-g user " Hello world! "모든 구성은 환경 변수를 통해 수행됩니다.
| 매개 변수 | 설명 | 기본 | 예 |
|---|---|---|---|
DEFAULT_MODEL_HG_REPO_ID | 포옹 페이스 리포 ID는 모델을 다운로드합니다 | None | TheBloke/orca_mini_3B-GGML |
DEFAULT_MODEL_HG_REPO_REVISION | 포옹 페이스 리포 개정 | main | gptq-4bit-32g-actorder_True |
DEFAULT_MODEL_FILE | repo에서 다운로드 할 파일 이름, GPTQ 모델의 선택 사항 | None | orca-mini-3b.ggmlv3.q4_0.bin |
MODE_TYPE | 모델 유형 자동 모델 유형 감지를 무시합니다 | None | gptq , gpt_bigcode , llama , mpt , replit , falcon , gpt_neox gptj |
LOGGING_LEVEL | 로깅 레벨 | INFO | DEBUG |
TOP_K | 샘플링을위한 최상위 K. | 40 | 정수 |
TOP_P | 샘플링을위한 상단 -P. | 1.0 | 부유물 |
REPETITION_PENALTY | 샘플링을위한 RP. | 1.1 | 부유물 |
LAST_N_TOKENS | 반복 페널티를위한 마지막 n 토큰. | 1.1 | 정수 |
SEED | 샘플링을위한 씨앗. | -1 | 정수 |
BATCH_SIZE | 토큰 평가를위한 배치 크기, GGUF/GGML 모델의 경우에만 | 8 | 정수 |
THREADS | 스레드 번호 재정의 자동 감지 CPU/2, GPTQ 모델의 1 세트 1 세트 | Auto | 정수 |
MAX_TOKENS | 생성 할 토큰의 최대 수 | 512 | 정수 |
STOP | 세대를 멈추는 토큰 | None | `< |
CONTEXT_LENGTH | 자동 감지 컨텍스트 길이를 무시하십시오 | 512 | 정수 |
GPU_LAYERS | gpu에 부하를 끄는 층 수 | 0 | 정수 |
TRUNCATE_PROMPT_LENGTH | 설정하면 프롬프트를 자릅니다 | 0 | 정수 |
TOP_K , TOP_P , REPETITION_PENALTY , LAST_N_TOKENS , SEED , MAX_TOKENS , STOP 포함한 샘플링 매개 변수는 예를 들어 요청 본문을 통해 요청 당 재정의 할 수 있습니다.
curl -X POST
-H ' Content-Type: application/json '
-d ' { "messages": [{"role": "user", "content": "Tell me a story."}], "model": "llama-2-7b-chat.ggmlv3.q4_0.bin", "stream": false, "temperature": "2", "top_p": "1.0", "top_k": "0" } '
http://localhost:8000/v1/chat/completions 이 요청에는 temperature=2 , top_p=1 및 top_k=0 사용합니다.
ghcr.io에서 호스팅 된 이미지가 있습니다 (또는 Cuda11, Cuda12, Metal, GPTQ 변형).
docker run --rm -it -p 8000:8000
-e DEFAULT_MODEL_HG_REPO_ID= " TheBloke/Llama-2-7B-Chat-GGML "
-e DEFAULT_MODEL_FILE= " llama-2-7b-chat.ggmlv3.q4_0.bin "
ghcr.io/chenhunghan/ialacol:latest개발자/기고자를 위해
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
DEFAULT_MODEL_HG_REPO_ID= " TheBloke/stablecode-completion-alpha-3b-4k-GGML " DEFAULT_MODEL_FILE= " stablecode-completion-alpha-3b-4k.ggmlv1.q4_0.bin " LOGGING_LEVEL= " DEBUG " THREAD=4 uvicorn main:app --reload --host 0.0.0.0 --port 9999이미지를 빌드하십시오
docker build --file ./Dockerfile -t ialacol .컨테이너를 실행하십시오
export DEFAULT_MODEL_HG_REPO_ID= " TheBloke/orca_mini_3B-GGML "
export DEFAULT_MODEL_FILE= " orca-mini-3b.ggmlv3.q4_0.bin "
docker run --rm -it -p 8000:8000
-e DEFAULT_MODEL_HG_REPO_ID= $DEFAULT_MODEL_HG_REPO_ID
-e DEFAULT_MODEL_FILE= $DEFAULT_MODEL_FILE ialacol GPU/CUDA 가속도를 활성화하려면 GPU 용 컨테이너 이미지를 사용하고 GPU_LAYERS 환경 변수를 추가해야합니다. GPU_LAYERS GPU 메모리의 크기에 따라 결정됩니다. 최고의 가치를 찾으려면 llama.cpp의 PR/토론을 참조하십시오.
deployment.image = ghcr.io/chenhunghan/ialacol-cuda11:latestdeployment.env.GPU_LAYERS GPU에로드를 꺼리는 계층입니다.deployment.image = ghcr.io/chenhunghan/ialacol-cuda12:latestdeployment.env.GPU_LAYERS GPU에로드를 꺼리는 계층입니다. llama , falcon , mpt 및 gpt_bigcode (Starcoder/Starchat) 만 Cuda를 지원합니다.
helm install llama2-7b-chat-cuda12 ialacol/ialacol -f examples/values/llama2-7b-chat-cuda12.yaml40 개의 레이어가 GPU에 오프로드 된 LLAMA2 7B 모델을 배포합니다. 추론은 Cuda 12에 의해 가속됩니다.
helm install starcoderplus-guanaco-cuda12 ialacol/ialacol -f examples/values/starcoderplus-guanaco-cuda12.yamlGPU에 40 개의 레이어를 오프로드 한 StarCoderPlus-Guanaco-GPT4-15B-V1.0 모델을 배치합니다. 추론은 Cuda 12에 의해 가속됩니다.
CUDA driver version is insufficient for CUDA runtime version 경우 CUDA 버전과 호환되지 않는 NVIDIA 드라이버를 사용하는 것일 수 있습니다.
노드에서 드라이버를 수동으로 업그레이드하십시오 (CUDA11 + AMI를 사용하는 경우 여기를 참조하십시오). 또는 Cuda의 다른 버전을 시도하십시오.
금속 지원을 가능하게하려면 금속을 위해 제작 된 이미지 ialacol-metal 사용하십시오.
deployment.image = ghcr.io/chenhunghan/ialacol-metal:latest예를 들어
helm install llama2-7b-chat-metal ialacol/ialacol -f examples/values/llama2-7b-chat-metal.yaml.yamlGPTQ를 사용하려면해야합니다
deployment.image = ghcr.io/chenhunghan/ialacol-gptq:latestdeployment.env.MODEL_TYPE = gptq예를 들어
helm install llama2-7b-chat-gptq ialacol/ialacol -f examples/values/llama2-7b-chat-gptq.yaml.yamlkubectl port-forward svc/llama2-7b-chat-gptq 8000:8000
openai -k " sk-fake " -b http://localhost:8000/v1 -vvvvv api chat_completions.create -m gptq_model-4bit-128g.safetensors -g user " Hello world! " GitHub의 부실은 OpenAI 완료 API와 거의 동일한 API이므로 ialacol Coplot 클라이언트로 사용할 수 있습니다.
그러나 명심해야 할 일은 거의 없습니다.
Coplelot Client는 코드 완료를위한 모든 관련 컨텍스트를 포함시키기 위해 Lenthy 프롬프트를 보냅니다. 서버에 큰 부하를 제공하는 Copilot-Explorer를 참조하십시오. 로컬로 ialacol 로 실행하려는 경우 옵트 인 TRUNCATE_PROMPT_LENGTH 변수가 처음부터 프롬프트를 절단하여 워크로드를 줄입니다.
Colecilot은 요청을 병렬로 보냅니다. 처리량을 늘리려면 텍스트-인식 배치와 같은 대기열이 필요할 것입니다.
Ialacol의 두 가지 인스턴스를 시작하십시오.
gh repo clone chenhunghan/ialacol && cd ialacol && python3 -m venv .venv && source .venv/bin/activate && python3 -m pip install -r requirements.txt
LOGGING_LEVEL= " DEBUG "
THREAD=2
DEFAULT_MODEL_HG_REPO_ID= " TheBloke/stablecode-completion-alpha-3b-4k-GGML "
DEFAULT_MODEL_FILE= " stablecode-completion-alpha-3b-4k.ggmlv1.q4_0.bin "
TRUNCATE_PROMPT_LENGTH=100 # optional
uvicorn main:app --host 0.0.0.0 --port 9998
uvicorn main:app --host 0.0.0.0 --port 9999상류 Ialacol 인스턴스를 가리키고 TIB를 시작하십시오.
gh repo clone ialacol/text-inference-batcher && cd text-inference-batcher && npm install
UPSTREAMS= " http://localhost:9998,http://localhost:9999 " npm startTIB를 사용하도록 VSCODE GITHUB COPOLOT를 구성하십시오.
"github.copilot.advanced" : {
"debug.overrideEngine" : " stablecode-completion-alpha-3b-4k.ggmlv1.q4_0.bin " ,
"debug.testOverrideProxyUrl" : " http://localhost:8000 " ,
"debug.overrideProxyUrl" : " http://localhost:8000 "
} LLM은 매개 변수에 민감한 것으로 알려져 있고, temperature 높을수록 "무작위성"이 많아서 LLM은 "창의적"이되며 top_p 및 top_k 도 "무작위성"에 기여합니다.
LLM을 창의적으로 만들고 싶다면.
curl -X POST
-H ' Content-Type: application/json '
-d ' { "messages": [{"role": "user", "content": "Tell me a story."}], "model": "llama-2-7b-chat.ggmlv3.q4_0.bin", "stream": false, "temperature": "2", "top_p": "1.0", "top_k": "0" } '
http://localhost:8000/v1/chat/completionsLLM을보다 일관성있게 만들고 동일한 입력으로 동일한 결과를 생성하려면
curl -X POST
-H ' Content-Type: application/json '
-d ' { "messages": [{"role": "user", "content": "Tell me a story."}], "model": "llama-2-7b-chat.ggmlv3.q4_0.bin", "stream": false, "temperature": "0.1", "top_p": "0.1", "top_k": "40" } '
http://localhost:8000/v1/chat/completionsstarcoder 모델 유형을 지원합니다.GET /models 및 POST /completions 포함하여 OpenAi API를 모방합니다. POST /embeddings 지원 TheBloke에 의해 정량화 된 Meta의 LLAMA 2 채팅 모델을 배치합니다.
7B 채팅
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install llama2-7b-chat ialacol/ialacol -f examples/values/llama2-7b-chat.yaml13B 채팅
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install llama2-13b-chat ialacol/ialacol -f examples/values/llama2-13b-chat.yaml70b 채팅
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install llama2-70b-chat ialacol/ialacol -f examples/values/llama2-70b-chat.yamlOpenllama 7B 모델을 배치하여 RustFormers에 의해 양자화됩니다.
이것은 기본 모델이며 텍스트 완료에만 유용 할 수 있습니다.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install openllama-7b ialacol/ialacol -f examples/values/openllama-7b.yamlOpenllama 13B Open Instruct 모델을 배치하십시오.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install openllama-13b-instruct ialacol/ialacol -f examples/values/openllama-13b-instruct.yamlRustformers에 의해 양자화 된 MosaicML의 MPT-7B 모델을 배포하십시오. 이것은 기본 모델이며 텍스트 완료에만 유용 할 수 있습니다.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install mpt-7b ialacol/ialacol -f examples/values/mpt-7b.yamlTheBloke에 의해 양자화 된 MosaicML의 MPT-30B 채팅 모델을 배포하십시오.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install mpt-30b-chat ialacol/ialacol -f examples/values/mpt-30b-chat.yaml무수정 FALCON 7B 모델을 배치하여 블로크에 의해 양자화됩니다.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install falcon-7b ialacol/ialacol -f examples/values/falcon-7b.yaml무수정 FALCON 40B 모델을 배치하여 TheBloke에 의해 양자화됩니다.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install falcon-40b ialacol/ialacol -f examples/values/falcon-40b.yaml TheBloke에 의해 정량화 된 starchat-beta 모델을 배포하십시오.
helm repo add starchat https://chenhunghan.github.io/ialacol
helm repo update
helm install starchat-beta ialacol/ialacol -f examples/values/starchat-beta.yaml TheBloke에 의해 양자화 된 WizardCoder 모델을 배포합니다.
helm repo add starchat https://chenhunghan.github.io/ialacol
helm repo update
helm install wizard-coder-15b ialacol/ialacol -f examples/values/wizard-coder-15b.yaml Rustformers에 의해 양자화 된 70 백만 개의 매개 변수 (~ 40MB)만으로 가벼운 pythia-70m 모델을 배포하십시오.
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install pythia70m ialacol/ialacol -f examples/values/pythia-70m.yaml RedPajama 3B 모델을 배포하십시오
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install redpajama-3b ialacol/ialacol -f examples/values/redpajama-3b.yaml stableLM 7B 모델을 배포하십시오
helm repo add ialacol https://chenhunghan.github.io/ialacol
helm repo update
helm install stablelm-7b ialacol/ialacol -f examples/values/stablelm-7b.yamlpython3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
pip freeze > requirements.txt