# Discourse AI - 셀프 호스팅 가이드

**URL:** https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598
**Category:** Self-Hosting
**Tags:** ai
**Created:** [4월 24, 2023, 7:40오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598 "2023-04-24T19:40:49Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [4월 24, 2023, 7:40오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/1 "2023-04-24T19:40:49Z")

</div>

이 가이드는 Discourse AI 모듈을 구동하는 서비스의 자체 인스턴스를 실행하는 방법에 대한 것입니다.

 

## 소개

자체 호스팅된 인스턴스에서 Discourse AI를 사용하려면 활성화하려는 모듈에 필요한 동반 서비스(companion services)를 실행해야 할 수 있습니다.

각 모듈에는 하나 이상의 필수 동반 서비스가 있으며, 이러한 서비스는 Discourse 자체보다 더 많은 CPU / GPU / 디스크 공간을 사용하므로, Linux 서버 관리와 Docker에 익숙하지 않은 분들에게는 권장하지 않습니다.

### 요약 / AI 헬퍼 / AI 봇

> [@DiscourseAI를 위한 오픈소스 LLM 셀프호스팅](https://meta.discourse.org/t/self-hosting-an-opensource-llm-for-discourseai/290923?u=falco):
>
> [Discourse AI](https://meta.discourse.org/t/discourse-ai/259214) 플러그인은 요약, AI 헬퍼, AI 검색, AI 봇과 같이 LLM이 활성화되어야 하는 여러 기능을 제공합니다. [OpenAI API 키 설정](https://meta.discourse.org/t/configure-api-keys-for-openai/280783)이나 [Anthropic API 키 설정](https://meta.discourse.org/t/configure-api-keys-for-anthropic/280936)과 같은 제3자 API를 사용할 수는 있지만, Discourse AI는 처음부터 이러한 서비스에 종속되지 않도록 설계되었습니다. HuggingFace TGI로 실행하기 HuggingFace는 빠르게 실행 환경을 구축할 수 있는 훌륭한 컨테이너 이미지를 제공합니다. 예를 들어: mkdir -p /opt/tgi-cache docker run --rm --gpus all --shm-size 1g -p 8080:80 \ -v /opt/tgi-cache:/data \ ghcr.io/huggingface/text-generation-inference:latest \ --model-id mistralai/Mistral-7B-Instruct-v0.2 이 명령어를 실행하면 로컬호스트의 …

### 임베딩(Embeddings)

> [@DiscourseAI 임베딩 셀프 호스팅](https://meta.discourse.org/t/self-hosting-embeddings-for-discourseai/290925?u=falco):
>
> The [Discourse AI](https://meta.discourse.org/t/discourse-ai/259214) plugin has many features that require embeddings to work, such as Related Topics, AI Search, AI Helper Category and Tag suggestion, etc. While you can use a third-party API, like [Configure API Keys for OpenAI](https://meta.discourse.org/t/configure-api-keys-for-openai/280783), [Configure API Keys for Cloudflare Workers AI](https://meta.discourse.org/t/configure-api-keys-for-cloudflare-workers-ai/283321) or [Configure API Keys for Google Gemini](https://meta.discourse.org/t/configure-api-keys-for-google-gemini/289556), we built Discourse AI from the first day to not be locked into those. Running with HuggingFace TEI HuggingFace provides an awesome container image that can get you running quickly. For …

### 감정 분석(Sentiment)

> [@DiscourseAI의 감정과 정서를 자체 호스팅하기](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451):
>
> The [Discourse AI](https://meta.discourse.org/t/discourse-ai/259214) plugin supports requesting emotion/sentiment classification for new posts, which is stored in the database and can be used in reports and admin dashboards. Discourse AI supports two types of classification, each requiring its own model: Sentiment — classifies posts as positive, negative, or neutral (using cardiffnlp/twitter-roberta-base-sentiment-latest) Emotion — classifies posts across 28 emotion labels such as joy, anger, surprise, etc. (using SamLowe/roberta-base-go\_emoti…

## 프로덕션 환경에서 실행

실제 운영 중인 사이트에서 실행할 때 로드 밸런싱, TLS, 헬스 체크, 레이트 리미트 등의 기능을 활성화하기 위해 이 서비스를 리버스 프록시 뒤에 두는 것을 고려할 수 있습니다.

서비스가 실행되면, 관리자 UI(관리자 \> 플러그인 \> Discourse AI)를 사용하여 모듈이 해당 서비스가 실행 중인 도메인에 연결하도록 설정한 후 모듈을 활성화하십시오.

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [4월 26, 2023, 12:10오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/2 "2023-04-26T12:10:25Z")

</div>

현재 자체 호스팅에서는 컴포저 헬퍼를 사용할 수 없나요?

이 개발과 구현을 위해 팀에게 감사드립니다 🔥🙌

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [4월 26, 2023, 1:06오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/3 "2023-04-26T13:06:08Z")

</div>

Composer Helper는 현재 OpenAI 또는 Anthropic API와만 작동하므로, 해당 API 중 하나를 보유하고 있다면 셀프호스팅 환경에서도 정상적으로 작동합니다.

---

<div class="post-metadata">

### Author: ![JoeD](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@JoeD](https://meta.discourse.org/u/JoeD)
#### Post date: [4월 28, 2023, 5:44오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/4 "2023-04-28T17:44:51Z")

</div>

Composer Helper를 성공적으로 실행했습니다. 감사합니다!

요약(Summarization) 기능에 로컬 분류 서비스가 필요한가요? 아니면 ChatGPT3.5 모델을 사용하는 경우 OpenAI API 키만으로 실행 가능한가요? 기능을 켰는데 주제(topics)에서 확인이 되지 않습니다.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [4월 28, 2023, 5:48오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/5 "2023-04-28T17:48:20Z")

</div>

> [@JoeD](#):
>
> 요약(Summarization) 기능이 로컬 분류 서비스가 필요한가요? 아니면 ChatGPT 3.5 모델을 사용할 경우 OpenAI API 키만 있으면 실행 가능한가요? 기능을 켰는데 주제 목록에서 보이지 않습니다.

[Discourse AI - Summarization](https://meta.discourse.org/t/discourse-ai-summarization/262711) 문서에 따르면, 이미 설정하신 OpenAI 키를 구성하고, GPT 모델 중 하나를 요약 모델로 선택한 후 요약 모듈을 활성화하면 OpenAI와 함께 사용할 수 있습니다.

현재 요약 버튼은 50개 이상의 답변이 있는 주제에만 표시되지만, 곧 모든 주제에 대해 활성화할 예정입니다.

---

<div class="post-metadata">

### Author: ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)
#### Post date: [4월 29, 2023, 7:45오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/7 "2023-04-29T19:45:24Z")

</div>

샘플 요청을 몇 가지 공유해 주시겠어요? 현재 AWS ASG의 EC2 인스턴스에서 설정을 시도 중인데, 제대로 작동하지 않습니다. Discourse 로그에는 400 Bad Request만 표시되고 있습니다.

또한, 헬스체크 URL이 있으면 좋겠습니다. `/` 경로에서는 404 오류가 발생합니다.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [4월 29, 2023, 7:58오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/8 "2023-04-29T19:58:16Z")

</div>

> [@nodomain](#):
>
> 또한, 헬스체크 URL이 있으면 좋겠습니다. `/`는 404 오류를 반환합니다.

`/srv/ok`와 `/health`가 헬스체크 엔드포인트입니다.

> [@nodomain](#):
>
> 샘플 요청을 공유해 주시겠습니까?

즉석에서 생각나는 예시는 다음과 같습니다:

```bash
jo -p model=bart-large-cnn-samsum content="Long sentence to summarize goes here" | \
  curl --json @- -XPOST http://service/api/v1/classify

```

요약 서비스에 대해서는 이렇게 작동해야 합니다.

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [4월 30, 2023, 10:04오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/10 "2023-04-30T22:04:23Z")

</div>

> [@Falco](#):
>
> 실제 사이트에서 실행할 때 로드 밸런싱, TLS, 헬스 체크, 레이트 리미트 등의 기능을 활성화하려면 이 서비스를 리버스 프록시 뒤에 두는 것이 좋습니다.

한도와 로드에 문제가 없다면, Nginx 모듈을 통한 헬스 체크와 함께 로컬호스트에서 요약 서비스를 사용하는 것을 제안할 수 있을까요?

저는 오픈소스 모델을 시도해 보고 싶을 뿐입니다. 현재는 OpenAI API 키를 사용하여 작동하도록 설정해 두었습니다.

ChatGPT3.5와 같이 호환성이 확보된 모델을 사용하여 다국어 요약을 활성화할 계획이 있나요?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [4월 30, 2023, 10:11오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/11 "2023-04-30T22:11:25Z")

</div>

> [@satonotdead](#):
>
> 제한 사항과 부하에 문제가 없다면, Nginx 모듈의 헬스체크와 함께 로컬호스트에서 요약 서비스를 사용하도록 제안할 수 있나요?

원하시는 방식이라면 작동할 것입니다.

> [@satonotdead](#):
>
> ChatGPT3.5와 같은 모델로 다국어 요약 기능을 활성화할 계획이 있나요? (호환 가능하게 만든 모델)

요약 기능은 이미 OpenAI와 Anthropic API에서 작동하므로, 이를 통해 다국어 기능을 얻을 수 있습니다. 다만, 주제 언어에 더 충실하게 유지하려면 프롬프트를 번역하기 위해 약간 수정해야 할 수 있습니다.

---

<div class="post-metadata">

### Author: ![nodomain](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nodomain/32/303402_2.png) [@nodomain](https://meta.discourse.org/u/nodomain)
#### Post date: [5월 3, 2023, 7:59오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/12 "2023-05-03T19:59:24Z")

</div>

AWS의 좋은 소식입니다: [Amazon RDS for PostgreSQL now supports pgvector for simplified ML model integration - AWS](https://aws.amazon.com/about-aws/whats-new/2023/05/amazon-rds-postgresql-pgvector-ml-model-integration/)

---

<div class="post-metadata">

### Author: ![Drew-ART](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@Drew-ART](https://meta.discourse.org/u/Drew-ART)
#### Post date: [6월 15, 2023, 10:19오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/13 "2023-06-15T22:19:47Z")

</div>

@Falco CPU / GPU / 디스크가 ‘충분한’ 서버 구성 예시를 하나 주실 수 있을까요? 평균적인 Discourse 포럼과 함께 셀프호스팅 AI를 실행할 수 있는 구성이요.

---

<div class="post-metadata">

### Author: ![DonH](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donh/32/274040_2.png) [@DonH](https://meta.discourse.org/u/DonH)
#### Post date: [6월 16, 2023, 4:12오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/14 "2023-06-16T16:12:31Z")

</div>

저도 그걸 보고 싶습니다. 또한, 자원 요구 사항에 비추어 볼 때, 컴패니언 AI 서비스를 별도의 VPS로 오프로딩하는 것이 더 나은 방법(가능할까요, 비용 대비 효율이 더 좋을까요?)이 될까요?

> > 서버 구성 예시

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [6월 16, 2023, 4:19오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/15 "2023-06-16T16:19:46Z")

</div>

실행하려는 Discourse AI의 정확한 모델과 모듈에 따라 달라집니다. 예를 들어 독성(toxicity) 모듈은 RAM 5GB, NSFW 모듈은 1GB를 사용합니다. 디스크 공간도 비슷하며, 추론(inference)에는 CPU/GPU가 사용되므로 필요한 자원은 초당 예상 요청 수에 따라 결정됩니다.

> [@DonH](#):
>
> 저도 그걸 보고 싶습니다. 또한, 리소스 요구 사항을 고려할 때 companion AI 서비스를 별도의 VPS로 오프로드하는 것이 더 나은 방법(가능할까요? 비용 대비 효율이 더 좋을까요?)이 될까요?

네, 그것이 아마도 가장 좋은 방법일 것입니다.

---

<div class="post-metadata">

### Author: ![Drew-ART](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@Drew-ART](https://meta.discourse.org/u/Drew-ART)
#### Post date: [6월 17, 2023, 4:04오전 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/16 "2023-06-17T04:04:55Z")

</div>

자, 한번 시도해 봤습니다:

대략적인 계산:

ChatGPTv4 API

- 100단어당 $0.0008
- 1명의 사용자는 각 AI 모듈에서 하루 평균 약 100단어(또는 토큰)를 사용
- 6개의 AI 모듈 전체 실행  
$0.0008 \* 6 = $0.0048

사용자당 월 총 비용: $0.0048 \* 30 = $0.144

자체 호스팅을 위한 최소 서버 요구 사항은 대략 다음과 같습니다:

- 16GB의 여유 RAM, 32GB 권장
- 3.5 GHz 이상 CPU 및 8개 이상의 코어
- 100GB SSD

Digital Ocean에서 이러한 요구 사항을 충족하는 가장 저렴한 서버는 다음과 같습니다:

- 16 GB RAM
- 8개 Premium Intel vCPU (3.5 GHz 초과)
- 대역폭: 6,000 GiB
- SSD: 2x 200 GiB
- 월 비용: $244.00

따라서 Discourse의 월 활성 사용자가 약 2,000명에 도달하면 ChatGPT4를 자체 호스팅하는 것이 API 서비스를 사용하는 것보다 비용 효율적입니다.

약간 불안정하고 관대한 반올림을 포함하고 있습니다. @Falco님, 이 정도면 맞을까요?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [6월 17, 2023, 5:39오전 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/17 "2023-06-17T05:39:39Z")

</div>

> [@Drew-ART](#):
>
> 그러니까 ChatGPT4를 셀프 호스팅하면 비용이 더 들겠네요

GPT-4나 3.5는 셀프 호스팅이 불가능합니다.

[Falcon](https://huggingface.co/blog/falcon)과 같은 일부 LLM은 오픈 소스이며, 다양한 LLaMA 기반 모델(라이선스 문제가 따름)도 셀프 호스팅이 가능합니다. 하지만 현재까지 이들 모델은 GPT-4는 물론 3.5보다 성능이 떨어집니다.

여기서 한 장의 휴지에 적어본 계산은 크게 어긋나 있습니다. LLM을 셀프 호스팅하려면 A100이나 H100, 어쩌면 그 이상을 필요로 할 텐데… 가격을 검색해 보세요…

---

<div class="post-metadata">

### Author: ![Drew-ART](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@Drew-ART](https://meta.discourse.org/u/Drew-ART)
#### Post date: [6월 17, 2023, 7:39오전 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/18 "2023-06-17T07:39:18Z")

</div>

ChatGPT를 이용해 자체 호스팅 비용을 계산하는 데 ChatGPT를 사용하면 이런 결과가 나오는구나 싶네요.

---

<div class="post-metadata">

### Author: ![Drew-ART](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@Drew-ART](https://meta.discourse.org/u/Drew-ART)
#### Post date: [6월 17, 2023, 8:12오전 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/19 "2023-06-17T08:12:16Z")

</div>

아무튼, 나중에 사용자 데이터를 비교할 수 있을 때 다시 돌아와서 업데이트를 하려고 합니다. 그리고 뭔가 기여할 수 있는 부분을 찾아보겠습니다.

위 모듈들을 ChatGPT3.5 API와 함께 사용할 때의 계산 결과를 공유합니다. 이 계산은 한 달 동안 평균적으로 활성 사용자가 한 번의 실행에서 100단어를 생성한다는 매우 모호한 가정에 기반하고 있습니다:

ChatGPT3.5 API 비용

- 1회 실행당 100단어당 $0.0003
- 활성 사용자 1인당 AI 모듈별 하루 평균 약 100단어

AI 플러그인/컴포넌트별 월 평균 비용: 0.009

- 6개 = $0.054

즉, 6개 플러그인 모두를 ChatGPT3.5로 실행할 경우 사용자 1인당 월 총 비용은 $0.054입니다.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [6월 29, 2023, 4:14오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/20 "2023-06-29T16:14:12Z")

</div>

> [@DonH](#):
>
> 서버 구성 예시

최근 Meta를 위해 `g4dn.xlarge` 인스턴스에서 AI 서비스를 시작했기 때문에, 이를 기준으로 추천할 수 있습니다.

---

<div class="post-metadata">

### Author: ![DonH](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/donh/32/274040_2.png) [@DonH](https://meta.discourse.org/u/DonH)
#### Post date: [6월 29, 2023, 5:48오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/21 "2023-06-29T17:48:18Z")

</div>

감사합니다. `g4dn.xlarge`가 무엇인지 궁금해하시는 분들을 위해 현재 요금제는 다음과 같습니다. 향후 활용률 데이터를 게시해 주실 수 있다면 실제 비용을 파악하는 데 도움이 될 것입니다.

> **[Amazon EC2 G4 Instances](https://aws.amazon.com/ec2/instance-types/g4/)**

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [6월 29, 2023, 5:55오후 UTC](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598/22 "2023-06-29T17:55:06Z")

</div>

> [@DonH](#):
>
> 실제 비용을 파악할 수 있도록 언젠가 활용도 데이터를 게시해 주셨으면 합니다.

해당 머신은 현재 메타 트래픽만 처리하고 있어 사실상 유휴 상태입니다. 메타 분량의 트래픽 몇 가지는 문제없이 처리할 수 있습니다.

[Next page](https://meta.discourse.org/t/discourse-ai-self-hosted-guide/259598.md?page=2)
