데보션앱 소개페이지 바로가기
로그인 선택

신고하기

CLOSE
신고사유 (대표 사유 1개)
상세내용 (선택)
0/200
  • 신고한 게시글은 더 이상 보이지 않습니다.
  • 이용약관과 운영정책에 따라 신고사유에 해당하는지 검토 후 조치됩니다.
  • 허위 신고인 경우, 신고자의 서비스 이용이 제한될 수 있으니 유의하시어 신중하게 신고해 주세요.
(이 회원이 작성한 모든 댓글과 커뮤니티 게시물이 보이지 않고, 알림도 오지 않습니다.)

미리보기

커뮤니티

      1,234

      badge 23.06.15

      글 등록

      카테고리를 선택해주세요.

      DEVOTEE를 활성화 시키면
      지금 작성한 커뮤니티 글에 대해 1개의 댓글을 달아줍니다.

      버튼을 누르면 글 수정 시 ChatGPT가 작성한 댓글이 수정됩니다.

      임시저장함에 저장되었습니다. 저장일시 : 2022.5.17 14:29:08

      임시저장함

      제목을 선택하시면 이어서 작성이 가능하며,
      최대 20건까지 저장합니다.
      컨텐츠 유형, 제목, 저장일시, 삭제로 이뤄진 임시저장 목록
      컨텐츠 유형 제목 저장일 삭제

      데보션 블로그 게재 요청

      CLOSE
      • *
      • *

      본인인증

      효율적인 데보션 서비스 이용 및
      고객님의 소중한 개인정보보호를 위해
      본인인증을 진행해주세요. 본인인증 미 진행 시 로그인이 제한됩니다.
      본인인증 실패

      본인인증 로그인에 실패하였습니다.
      회원이 아니시거나 본인인증 등록이
      완료되지 않은 사용자입니다.

      회원정보 연결

      정보 유출 걱정없이 AI를 사용해보자. "LocalAI"

      goto 24.03.06
      16,709 11 4
      DEVOTEE 요약
      LocalAI는 공개된 AI 코드인 OpenAI의 대안으로, 로컬 환경에서 작동해 정보 유출 걱정 없이 AI를 활용할 수 있다. Python 등 다양한 언어로 작성된 백엔드와 호환되며, 다양한 종류의 모델을 지원하여 CPU와 GPU 모두에서 추론을 수행할 수 있다. 사용자는 인터넷 연결이나 GPU 없이도 AI 모델을 활용할 수 있으며, 오픈AI와 동일한 API를 제공함으로써 로컬 환경이나 온-프레미스 환경에서도 AI를 쉽게 활용할 수 있다.
      DEVOTEE 추천 블로그

      개요

      생성형 AI에 대한 관심이 높아지고 있지만 많은 사용자들과 기업들은 외부 서버에 있는 AI에 내 정보가 유출되어 학습에 사용되고, 이것이 제 3자에게 유출되는 것을 두려워합니다.

      Internet 없는 Local 환경에서 동작할 수 있어 외부로 정보 유출 걱정 없이 AI를 쉽게 사용할 수 있도록 지원하고자 등장한 것이 LocalAI입니다.

      LocalAI에 대해서 알아보고 간단하게 적용해보도록 하겠습니다.

      image.png


      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의 모든 구성 요소에 대해 알아볼 수 있습니다.


      Star History

      Star History Chart


      LocalAI 설치

      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: {}
      
      EOF
      • local-ai chart 설치

      helm install local-ai go-skynet/local-ai -f values.yaml
      • local-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
         }'
      • 결과

        image.png


      결론

      • LocalAI는 internet, GPU없이 AI 모델 사용이 가능합니다.

      • openAI와 동일한 API를 제공합니다.

      • 이를 통해 local이나 on-prem 환경의 고객 hardware를 이용하여 AI를 사용할 수 있습니다.

      댓글 0

      DEVOTEE를 활성화 시키면
      지금 작성한 댓글에 AI가 댓글을 달아줍니다.

      goto 님의 최신 블로그

      더보기

      DEVOTEE 추천 블로그

      동영상 기고하기