# DiscourseAI의 감정과 정서를 자체 호스팅하기

**URL:** https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451
**Category:** Self-Hosting
**Tags:** ai, ai-sentiment
**Created:** [11월 4, 2024, 5:56오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451 "2024-11-04T17:56:42Z")
**Posts on this page:** 18
**Page:** 1

<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: [11월 4, 2024, 5:56오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/1 "2024-11-04T17:56:42Z")

</div>

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_emotions`)

To get both sentiment and emotion data in your dashboards, you need to run **both** models.

### Running with HuggingFace TEI

HuggingFace provides an excellent container image that allows you to get up and running quickly.

#### Sentiment model

```plaintext
mkdir -p /opt/tei-sentiment-cache
docker run --rm --gpus all --shm-size 1g -p 8081:80 \
  -v /opt/tei-sentiment-cache:/data \
  ghcr.io/huggingface/text-embeddings-inference:latest \
  --model-id cardiffnlp/twitter-roberta-base-sentiment-latest \
  --revision refs/pr/30

```

This should get you up and running with a local instance of `cardiffnlp/twitter-roberta-base-sentiment-latest`, an open model that can classify posts into positive/negative/neutral.

You can check if it’s working with

```bash
curl http://localhost:8081/ \
    -X POST \
    -H 'Content-Type: application/json' \
    -d "{ \"inputs\": \"I am happy\" }"

```

Which should return an array of confidence scores for each label under normal operation.

#### Emotion model

To also get emotion classification, run a second container with the emotion model:

```plaintext
mkdir -p /opt/tei-emotion-cache
docker run --rm --gpus all --shm-size 1g -p 8082:80 \
  -v /opt/tei-emotion-cache:/data \
  ghcr.io/huggingface/text-embeddings-inference:latest \
  --model-id SamLowe/roberta-base-go_emotions

```

### Supported models

- [cardiffnlp/twitter-roberta-base-sentiment-latest · Hugging Face](https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest/) — sentiment (positive/negative/neutral)
- [SamLowe/roberta-base-go\_emotions · Hugging Face](https://huggingface.co/SamLowe/roberta-base-go_emotions) — emotion (28 emotion labels)

### Making it available for your Discourse instance

Most of the time, you will be running this on a dedicated server because of the GPU speed-up. When doing so, I recommend running a reverse proxy, doing TLS termination, and securing the endpoint so it can only be connected to by your Discourse instance.

### Configuring Discourse AI

Discourse AI includes site settings to configure the inference server for open-source models. You should point it to your server using the **ai\_sentiment\_model\_configs** setting.

This setting accepts a JSON array of model configurations. Each entry requires:

| Field | Description |
| --- | --- |
| `model_name` | The HuggingFace model ID (e.g. `cardiffnlp/twitter-roberta-base-sentiment-latest`) |
| `endpoint` | The URL of your TEI instance (e.g. `https://your-server:8081`) |
| `api_key` | API key for the endpoint (can be left blank if not required) |

To get both sentiment and emotion dashboards, add an entry for **each** model you are running. For example, if you’re running both models locally:

- Entry 1: model\_name `cardiffnlp/twitter-roberta-base-sentiment-latest`, endpoint `https://your-server:8081`
- Entry 2: model\_name `SamLowe/roberta-base-go_emotions`, endpoint `https://your-server:8082`

After that, enable the classification by toggling `ai_sentiment_enabled`.

---

<div class="post-metadata">

### Author: ![haozi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haozi/32/381818_2.png) [@haozi](https://meta.discourse.org/u/haozi)
#### Post date: [12월 4, 2024, 2:17오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/2 "2024-12-04T02:17:54Z")

</div>

영어 이외의 언어로 다른 모델을 지원할 계획이 있나요?

---

<div class="post-metadata">

### Author: ![RBoy](https://avatars.discourse-cdn.com/v4/letter/r/2bfe46/32.png) [@RBoy](https://meta.discourse.org/u/RBoy)
#### Post date: [3월 26, 2025, 1:45오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/4 "2025-03-26T01:45:07Z")

</div>

> [@Falco](#):
>
> 대부분의 경우 GPU 가속 덕분에 이 작업은 전용 서버에서 실행하게 됩니다.

@Falco 디스코urses와 동일한 서버에서 이 작업을 실행하기로 결정하는 경우(예: 게시물 수천 건 규모의 매우 작은 배포 환경), 설명서를 업데이트하여 다음 사항을 명시해 주실 수 있을까요?

1. 디스코urses가 로컬 HuggingFace TEI 컨테이너 이미지와 어떻게 통합되는지
2. 위와 같은 작업을 실행하는 데 필요한 추가 RAM/디스크 용량에 대한 제안(예: 기본 디스코urses가 2GB RAM과 20GB 디스크에서 실행되고 있는 경우)

---

<div class="post-metadata">

### Author: ![agent\_kith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agent_kith/32/541510_2.png) [@agent\_kith](https://meta.discourse.org/u/agent_kith)
#### Post date: [6월 20, 2025, 4:06오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/5 "2025-06-20T04:06:40Z")

</div>

새로운 자체 호스팅 Discourse 인스턴스를 설정하고 감성 분석(sentiments)을 설정하려고 하고 있습니다. 제 ai\_sentiment\_model\_configs는 다음과 같습니다.

| 키 | 값 |
| --- | --- |
| 모델 이름 | cardiffnlp/twitter-roberta-base-sentiment-latest |
| 엔드포인트 | https://my\_own\_instance |
| api\_key | [비어 있음] |

이것이 어느 정도 작동하여 감성 막대 그래프는 표시됩니다.

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/0/0/4005bae28fb2155dcb002027dc66899a0c34651b.png)

하지만 감정(Emotion) 테이블은 비어 있습니다. 이 문서는 제가 해야 할 일을 파악하기에는 불완전하거나 표현이 불분명해 보입니다.

다른 모델 ID(roberta-base-go\_emotions?)를 사용하여 별도의 Docker 컨테이너를 실행해야 하는 건가요, 아니면 다른 조치를 취해야 하는 건가요? 그 감정 테이블을 채우려면 무엇을 해야 하나요?

가능하다면 이 서비스들도 자체 호스팅하는 것을 선호합니다. 올바른 방향으로 안내해 주시면 감사하겠습니다.

---

<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월 20, 2025, 3:26오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/6 "2025-06-20T15:26:33Z")

</div>

> [@agent\_kith](#):
>
> 하지만 Emotion 테이블은 비어 있습니다. 이 문서는 불완전하거나, 제가 무엇을 해야 하는지 파악하기 어려울 정도로 표현이 부실한 것 같습니다.
> 
> 다른 모델 ID(roberta-base-go\_emotions?)로 Docker 컨테이너를 다시 실행해야 하는지, 아니면 다른 조치를 취해야 하는 건가요? Emotion 테이블에 데이터를 채우려면 무엇을 해야 하나요?

감정을 처리하려면 다음을 실행해야 합니다.

> [@Falco](#):
>
> [SamLowe/roberta-base-go\_emotions · Hugging Face](https://huggingface.co/SamLowe/roberta-base-go_emotions)

도.

---

<div class="post-metadata">

### Author: ![agent\_kith](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agent_kith/32/541510_2.png) [@agent\_kith](https://meta.discourse.org/u/agent_kith)
#### Post date: [6월 21, 2025, 12:34오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/7 "2025-06-21T00:34:38Z")

</div>

감사합니다. 그래서 다음과 같이 몇 가지 설정을 조정하여 두 번째 docker 컨테이너를 실행했습니다:

```plaintext
mkdir -p /opt/tei-cache2
docker run --detach --rm --gpus all --shm-size 1g -p 8082:80 \
  -v /opt/tei-cache2:/data \
  ghcr.io/huggingface/text-embeddings-inference:latest \
  --model-id SamLowe/roberta-base-go_emotions

```

그리고 `ai_sentiment_model_configs`에 새 항목을 추가하니 이제 모든 것이 정상적으로 작동합니다. 감사합니다. 🙂

---

<div class="post-metadata">

### Author: ![Lee\_Ars](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lee_ars/32/1597_2.png) [@Lee\_Ars](https://meta.discourse.org/u/Lee_Ars)
#### Post date: [8월 17, 2025, 6:39오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/8 "2025-08-17T18:39:38Z")

</div>

GPU 없이 EC2 인스턴스에서 이걸 작동시키는 방법을 모르겠다며 벽에 머리를 박고 부딪혔습니다. 적어도 제 극도로 제한된 능력과 이해 범위 내에서는, CPU 전용 인스턴스로 이 작업을 하려면 제가 이해할 수 있는 것보다 훨씬 더 많은 구성 작업이 필요해 보입니다. `ghcr.io/huggingface/text-embeddings-inference`의 `cpu` 버전은 나열된 두 모델 중 어느 것도 로드하기를 거부합니다. Claude와 GPT5 모두 제가 일련의 Python 도구를 사용하여 모델들을 ONNX 모델로 변환해야 한다고 말했고, 바로 그 지점에서 저는 포기했습니다.

(아마도 저는 그저 멍청해서 자명한 단계를 놓치고 있는 것일 수도 있습니다!)

---

<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: [8월 17, 2025, 11:17오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/9 "2025-08-17T23:17:21Z")

</div>

우리가 계획하고 있는 것 중 하나는 LLM을 감정 분석에 활용하는 것입니다.

이렇게 하면 Gemini Flash 2.5(또는 nano)와 같은 저렴한 모델을 감정 분석에 사용할 수 있습니다.

---

<div class="post-metadata">

### Author: ![Neil\_Evans2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil_evans2/32/492791_2.png) [@Neil\_Evans2](https://meta.discourse.org/u/Neil_Evans2)
#### Post date: [8월 27, 2025, 8:35오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/10 "2025-08-27T08:35:04Z")

</div>

> [@Falco](#):
>
> cardiffnlp/twitter-roberta-base-sentiment-latest

자체 호스팅된 Discourse 인스턴스에서 Azure AI Language를 사용하여 이 기능을 적용하려고 하고 있습니다. 이미 GPT-4.5를 Discourse에 통합(요약 및 챗봇 기능)하기 위해 Azure 구독을 사용하고 있기 때문입니다:

> **[What is Azure Language in Foundry Tools - Foundry Tools](https://learn.microsoft.com/en-us/azure/ai-services/language-service/overview)**
>
> Learn how to integrate AI into your applications that can extract information and understand written language.

- 하지만 감정 분석 대시보드에 데이터가 표시되지 않으며, 로그에서 다음과 같은 오류를 확인할 수 있습니다:

`Discourse AI: Errors during bulk classification: Failed to classify 208 posts (example ids: 2256, 909, 2270, 2260, 2797) : JSON::ParserError : An empty string is not a valid JSON string.`

스택 트레이스에 따르면 Discourse가 HuggingFace를 사용하려고 시도하는 것 같습니다. 현재 지원되는 모델이 이것뿐인가요?

감사합니다.

N

---

<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: [8월 27, 2025, 11:47오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/11 "2025-08-27T23:47:23Z")

</div>

네, 저희는 매우 구체적인 구현 방식을 가지고 있으며, 이를 더 범용적으로 만드는 방법에 대해 고민하고 있습니다.

감정 분석(sentiment)에 대해 LLM이 구조화된 출력을 반환하도록 하는 방식에는 낙관적입니다. 이 방식이 다양한 옵션을 열어주기 때문이죠. 또한, LLM이 제공하는 “초범용(hyper general)” API가 “초구체적(hyper specific)” API를 대체해 나가는 추세라고 느끼고 있습니다.

---

<div class="post-metadata">

### Author: ![dylanb](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dylanb/32/139102_2.png) [@dylanb](https://meta.discourse.org/u/dylanb)
#### Post date: [8월 28, 2025, 1:03오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/12 "2025-08-28T01:03:10Z")

</div>

감정 분류를 위한 인스턴스를 직접 설정하지 않고 자체 호스팅된 워드프레스에서 이 기능을 바로 실행할 수 있는 간단한 방법이 있나요?

---

<div class="post-metadata">

### Author: ![Neil\_Evans2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil_evans2/32/492791_2.png) [@Neil\_Evans2](https://meta.discourse.org/u/Neil_Evans2)
#### Post date: [8월 28, 2025, 4:10오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/13 "2025-08-28T16:10:02Z")

</div>

샘, 감사합니다. 정말 좋겠습니다. 그 동안 Azure VM에서 지원되는 HuggingFace 모델 중 하나를 실행하는 방법을 알아볼 예정이랍니다…

---

<div class="post-metadata">

### Author: ![NotAnonymous](https://avatars.discourse-cdn.com/v4/letter/n/f05b48/32.png) [@NotAnonymous](https://meta.discourse.org/u/NotAnonymous)
#### Post date: [5월 12, 2026, 8:49오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/14 "2026-05-12T20:49:44Z")

</div>

셀프호스팅 감정 분석(sentiment)을 설정하려고 하는데, Docker 이미지를 실행하면 오류가 발생합니다:

```plaintext
0: request error: HTTP status client error (404 Not Found) for url (https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest/resolve/main/tokenizer.json)
1: HTTP status client error (404 Not Found) for url (https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest/resolve/main/tokenizer.json)

```

사용 중인 명령어는 다음과 같습니다: `docker run --rm --shm-size 1g -p 8083:80 -v /opt/tei-sentiment-cache:/data ghcr.io/huggingface/text-embeddings-inference:cpu-1.9 --model-id cardiffnlp/twitter-roberta-base-sentiment-latest`

GPU 지원이 없는 환경에서는 지원되지 않는 건가요, 아니면 설정 방식이 변경된 건가요?

---

<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: [5월 12, 2026, 9:16오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/15 "2026-05-12T21:16:39Z")

</div>

음, 아직 [모델에 대한 내 PR](https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment-latest/discussions/30)이 병합되지 않은 것 같으니, 내 브랜치를 직접 지정해야 합니다. 위에서 감정 분석 모델용 docker 명령어를 업데이트했으니, 브랜치를 가리키기 위한 추가 줄과 함께 시도해 보세요.

---

<div class="post-metadata">

### Author: ![NotAnonymous](https://avatars.discourse-cdn.com/v4/letter/n/f05b48/32.png) [@NotAnonymous](https://meta.discourse.org/u/NotAnonymous)
#### Post date: [5월 12, 2026, 9:24오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/16 "2026-05-12T21:24:43Z")

</div>

고마워요, 성공한 것 같아요!

---

<div class="post-metadata">

### Author: ![Orioni](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/orioni/32/542679_2.png) [@Orioni](https://meta.discourse.org/u/Orioni)
#### Post date: [5월 27, 2026, 10:50오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/17 "2026-05-27T10:50:29Z")

</div>

2025년 8월에 보낸 이 메시지에 대한 후속 질문입니다. 다른 LLM과의 연결에 대한 예상 완료일(ETA)이 혹시 있으신가요?

현재 Gemini 3 Flash를 사용하고 있으며, AI를 직접 호스팅하지 않아도 임베딩을 수행할 수 있어 긍정적인 경험을 하고 있습니다. 비용을 절감하기 위해 곧 Gemini 3.1 Flash-Lite로 전환할 예정입니다. 감정 분석에 이러한 Gemini LLM을 사용할 수 있기를 진심으로 희망합니다. 매일 Discourse를 사용하는 것이 정말 좋습니다. 사용 경험이 매우 훌륭합니다.

감사합니다.

---

<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: [5월 27, 2026, 4:17오후 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/18 "2026-05-27T16:17:12Z")

</div>

어제 추가했는데, 곧 웹사이트에 표시될 것입니다.

---

<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: [8월 12, 2026, 2:29오전 UTC](https://meta.discourse.org/t/self-hosting-sentiment-and-emotion-for-discourseai/334451/19 "2026-08-12T02:29:54Z")

</div>

감정 분류기를 더 적은 이모지로 줄이는 것이 가능할까요?

대시보드의 일부 이모지가 완전히 표시되지 않을 수 있다는 점은 알고 있습니다. 하지만 28개에서 10개 이하로 줄이려는 것이 제 목표이므로, 저에게는 문제가 되지 않습니다.
