23.06.15
DEVOTEE를 활성화 시키면
지금 작성한 커뮤니티 글에 대해 1개의 댓글을 달아줍니다.
버튼을 누르면 글 수정 시 ChatGPT가 작성한 댓글이 수정됩니다.
| 컨텐츠 유형 | 제목 | 저장일 | 삭제 |
|---|
본인인증 로그인에 실패하였습니다.
회원이 아니시거나 본인인증 등록이
완료되지 않은 사용자입니다.
생성형 AI에 대한 관심이 높아지고 있지만 많은 사용자들과 기업들은 외부 서버에 있는 AI에 내 정보가 유출되어 학습에 사용되고, 이것이 제 3자에게 유출되는 것을 두려워합니다.
Internet 없는 Local 환경에서 동작할 수 있어 외부로 정보 유출 걱정 없이 AI를 쉽게 사용할 수 있도록 지원하고자 등장한 것이 LocalAI입니다.
LocalAI에 대해서 알아보고 간단하게 적용해보도록 하겠습니다.
LocalAI는 무료 오픈 소스 OpenAI 대안입니다.
LocalAI는 로컬 추론을 위한 OpenAI API 사양과 호환되는 드롭인 대체 REST API 역할을 합니다.
LLM을 실행하고 이미지, 오디오(및 소비자 등급 하드웨어로 로컬 또는 온프레미스에서 생성할 수 있으며 여러 모델 제품군 및 아키텍처를 지원합니다.
GPU가 필요하지 않습니다.
LocalAI는 Go로 작성된 API로 이미 OpenAI SDK로 개발된 소프트웨어를 LocalAI와 원활하게 통합할 수 있도록 해줍니다.
ggml을 포함한 다양한 C++ 백엔드를 사용하여 CPU와 GPU를 모두 사용하여 LLM에 대한 추론을 수행함으로써 소비자 수준의 하드웨어에서도 대체물로 쉽게 구현할 수 있다.
Local AI는 다양한 언어(C++, Golang, Python 등)로 작성된 백엔드를 혼합하여 사용합니다.
모델 호환성 표를 확인하여 Local AI의 모든 구성 요소에 대해 알아볼 수 있습니다.
LocalAI는 다양한 환경에서 쉽게 설치할 수 있도록 설치 가이드를 제공한다.
그중 helm chart를 이용한 설치 방법을 이용하여 설치해보도록 하자.
helm chart 다운로드
helm repo add go-skynet https://go-skynet.github.io/helm-charts/values.yaml 파일 작성
cat <<EOF > values.yaml
replicaCount: 1
deployment:
image: quay.io/go-skynet/local-ai:latest
env:
threads: 4
context_size: 512
modelsPath: "/models"
resources:
{}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# Prompt templates to include
# Note: the keys of this map will be the names of the prompt template files
promptTemplates:
{}
# ggml-gpt4all-j.tmpl: |
# The prompt below is a question to answer, a task to complete, or a conversation to respond to; decide which and write an appropriate response.
# ### Prompt:
# {{.Input}}
# ### Response:
# Models to download at runtime
models:
# Whether to force download models even if they already exist
forceDownload: false
# The list of URLs to download models from
# Note: the name of the file will be the name of the loaded model
list:
- url: "https://gpt4all.io/models/gguf/gpt4all-falcon-newbpe-q4_0.gguf"
# basicAuth: base64EncodedCredentials
# Persistent storage for models and prompt templates.
# PVC and HostPath are mutually exclusive. If both are enabled,
# PVC configuration takes precedence. If neither are enabled, ephemeral
# storage is used.
persistence:
pvc:
enabled: false
size: 6Gi
accessModes:
- ReadWriteOnce
annotations: {}
# Optional
storageClass: ~
hostPath:
enabled: false
path: "/models"
service:
type: ClusterIP
port: 80
annotations: {}
# If using an AWS load balancer, you'll need to override the default 60s load balancer idle timeout
# service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "1200"
ingress:
enabled: false
className: ""
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
nodeSelector: {}
tolerations: []
affinity: {}
EOFlocal-ai chart 설치
helm install local-ai go-skynet/local-ai -f values.yamllocal-ai 동작 확인
Defaulted container "local-ai" out of: local-ai, download-model (init)
@@@@@
Skipping rebuild
@@@@@
If you are experiencing issues with the pre-compiled builds, try setting REBUILD=true
If you are still experiencing issues with the build, try setting CMAKE_ARGS and disable the instructions set as needed:
CMAKE_ARGS="-DLLAMA_F16C=OFF -DLLAMA_AVX512=OFF -DLLAMA_AVX2=OFF -DLLAMA_FMA=OFF"
see the documentation at: https://localai.io/basics/build/index.html
Note: See also https://github.com/go-skynet/LocalAI/issues/288
@@@@@
CPU info:
model name : Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology n_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cdp_l3 invpcid_single pti intel_ppin tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap intel_pt xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts
CPU: AVX found OK
CPU: AVX2 found OK
CPU: no AVX512 found
@@@@@
11:58PM DBG no galleries to load
11:58PM INF Starting LocalAI using 4 threads, with models path: /models
11:58PM INF LocalAI version: v2.7.0 (abd678e147e29ab46a038d28c4806768b2b7cde5)
11:58PM INF Preloading models from /models
┌───────────────────────────────────────────────────┐
│ Fiber v2.50.0 │
│ http://127.0.0.1:8080 │
│ (bound on host 0.0.0.0 and port 8080) │
│ │
│ Handlers ............ 73 Processes ........... 1 │
│ Prefork ....... Disabled PID ................ 14 │
└───────────────────────────────────────────────────┘
12:01AM INF Trying to load the model 'gpt4all-falcon-newbpe-q4_0.gguf' with all the available backends: llama-cpp, llama-ggml, llama, gpt4all, gptneox, bert-embeddings, falcon-ggml, gptj, gpt2, dolly, mpt, replit, starcoder, rwkv, whisper, stablediffusion, tinydream, piper, /build/backend/python/exllama/run.sh, /build/backend/python/exllama2/run.sh, /build/backend/python/sentencetransformers/run.sh, /build/backend/python/mamba/run.sh, /build/backend/python/vall-e-x/run.sh, /build/backend/python/transformers-musicgen/run.sh, /build/backend/python/bark/run.sh, /build/backend/python/transformers/run.sh, /build/backend/python/autogptq/run.sh, /build/backend/python/diffusers/run.sh, /build/backend/python/coqui/run.sh, /build/backend/python/petals/run.sh, /build/backend/python/vllm/run.sh, /build/backend/python/sentencetransformers/run.sh
12:01AM INF [llama-cpp] Attempting to load
12:01AM INF Loading model 'gpt4all-falcon-newbpe-q4_0.gguf' with backend llama-cpp
12:01AM INF [llama-cpp] Loads OK테스트
#LocalAI는 openAI에서 지원하는 API를 지원한다.
#LocalAI pod에 들어가서 하기와 같이 curl 명령어를 수행하면 된다.
#content에 원하는 질문을 넣으면 된다.
curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "gpt4all-falcon-newbpe-q4_0.gguf",
"messages": [{"role": "user", "content": "do you know k8s?"}],
"temperature": 0.9
}'결과
LocalAI는 internet, GPU없이 AI 모델 사용이 가능합니다.
openAI와 동일한 API를 제공합니다.
이를 통해 local이나 on-prem 환경의 고객 hardware를 이용하여 AI를 사용할 수 있습니다.
DEVOTEE를 활성화 시키면
지금 작성한 댓글에 AI가 댓글을 달아줍니다.