File size: 1,514 Bytes
ed9c7a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---

title: CertWeb Contrastive Embedding API
sdk: docker
app_port: 7860
---


# Contrastive Embedding API

CertWeb RAG용 **질의 → 768-dim 벡터** 임베딩을 Hugging Face Spaces에서 서빙합니다.  
모델은 HF **모델 리포**에서 로드하며, 이 Space 리포에는 모델 파일을 올리지 않습니다.

## 1. 모델 리포에 올리기

`HUGGINGFACE_UPLOAD.md` §2 참고: `model.safetensors`, `config.json`, `tokenizer*.json`, `config_sentence_transformers.json`, `modules.json`, `1_Pooling/config.json` 등.

## 2. 이 Space 만들기

1. **New Space** → 이름 예: `certweb-contrastive-embed`, **SDK: Docker** 선택.
2. 아래 **올릴 파일 목록**의 파일만 이 Space 리포에 업로드:
   - `app.py`, `requirements.txt`, `Dockerfile`, `README.md`
3. Space **Settings****Variables**:
   - `HF_MODEL_ID`: 모델 repo ID (예: `your-org/your-model-id`)
   - (비공개 리포면) `HF_TOKEN`: HF 토큰

## 3. CertWeb 백엔드에 연결

Render `.env`:

```env

RAG_CONTRASTIVE_ENABLE=true

RAG_CONTRASTIVE_EMBEDDING_URL=https://<your-org>-certweb-contrastive-embed.hf.space

```

Space가 제공하는 **API URL** (예: `https://xxx.hf.space` 또는 별도 API 경로)을 그대로 넣으면 됩니다.

## API 규약

- **POST /**  
  Body: `{"inputs": "질의 문자열"}`  
  Response: `[[float, ...]]` (768-dim 벡터 1개를 리스트로 감싼 형태)

- **GET /health**  
  Response: `{"status": "ok", "model_loaded": true}`