Skip to content

Commit

Permalink
refactor: 임베딩 모델 로컬 모델로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
ezcolin2 committed Feb 11, 2025
1 parent 7f3fcc8 commit fc87d10
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile.module
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# node_modules를 가지고 있는 이미지
# 이 이미지를 기반으로 각 workspace 별 이미지를 만들면
# yarn install 레이어를 공유하게 된다.
FROM node:20-alpine
FROM node:20-slim

WORKDIR /app

Expand All @@ -12,4 +12,4 @@ COPY apps/frontend/package.json ./apps/frontend/
COPY apps/websocket/package.json ./apps/websocket/

# 의존성 설치
RUN yarn install
RUN yarn install --check--files && yarn cache clean
2 changes: 2 additions & 0 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.693.0",
"@huggingface/transformers": "^3.3.3",
"@langchain/community": "^0.3.28",
"@langchain/core": "^0.3.37",
"@langchain/openai": "^0.4.2",
"@langchain/textsplitters": "^0.1.0",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.3.0",
"@nestjs/core": "^10.0.0",
Expand Down
6 changes: 3 additions & 3 deletions apps/backend/src/langchain/langchain.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
PGVectorStore,
DistanceStrategy,
} from '@langchain/community/vectorstores/pgvector';
import { OpenAIEmbeddings } from '@langchain/openai';
import { PoolConfig } from 'pg';
import type { Document } from '@langchain/core/documents';
import { v4 as uuidv4 } from 'uuid';
import { ChatOpenAI } from '@langchain/openai';
import { pull } from 'langchain/hub';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import { HuggingFaceTransformersEmbeddings } from '@langchain/community/embeddings/huggingface_transformers';

const llm = new ChatOpenAI({
model: 'gpt-4o-mini',
Expand All @@ -21,8 +21,8 @@ type DocumentInfo = {
content: string;
};
// Embeddings 초기화
const embeddings = new OpenAIEmbeddings({
model: 'text-embedding-3-small',
const embeddings = new HuggingFaceTransformersEmbeddings({
model: 'Xenova/all-MiniLM-L6-v2',
});

@Injectable()
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/features/AI/ui/QuestionForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export function QuestionForm({
},
);

const reader = response.body
.pipeThrough(new TextDecoderStream())
const reader = response
.body!!.pipeThrough(new TextDecoderStream())
.getReader();
while (true) {
const { value, done } = await reader.read();
Expand Down
2 changes: 1 addition & 1 deletion services/module/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# COPY 명령어는 여러 디렉토리를 목적지로 파일 복사하는 것이 불가능하다.
# 빌드 스테이지에서 COPY 명령어를 여러 번 생성해서 여러 디렉토리로 파일을 복사한다.
# 그 후 그 디렉토리 자체를 다음 스테이지에서 그대로 복사하여 layer의 개수를 줄인다.
FROM node:20-alpine as builder
FROM node:20-slim as builder

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion services/module/Dockerfile.init
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# COPY 명령어는 여러 디렉토리를 목적지로 파일 복사하는 것이 불가능하다.
# 빌드 스테이지에서 COPY 명령어를 여러 번 생성해서 여러 디렉토리로 파일을 복사한다.
# 그 후 그 디렉토리 자체를 다음 스테이지에서 그대로 복사하여 layer의 개수를 줄인다.
FROM node:20-alpine as builder
FROM node:20-slim as builder

WORKDIR /app

Expand Down
374 changes: 368 additions & 6 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit fc87d10

Please sign in to comment.