Spaces:
Sleeping
Sleeping
File size: 3,496 Bytes
526927a |
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# Lily LLM API - Hugging Face Spaces
## ๐ค ์๊ฐ
Lily LLM API๋ ๋ค์ค ๋ชจ๋ธ ์ง์๊ณผ RAG(Retrieval Augmented Generation) ์์คํ
์ ๊ฐ์ถ ๊ณ ์ฑ๋ฅ AI API ์๋ฒ์
๋๋ค.
### โจ ์ฃผ์ ๊ธฐ๋ฅ
- **๐ง ๋ฉํฐ๋ชจ๋ฌ AI**: Kanana-1.5-v-3b-instruct ๋ชจ๋ธ์ ํตํ ํ
์คํธ ๋ฐ ์ด๋ฏธ์ง ์ฒ๋ฆฌ
- **๐ RAG ์์คํ
**: ๋ฌธ์ ๊ธฐ๋ฐ ์ง์์๋ต ๋ฐ ์ปจํ
์คํธ ๊ฒ์
- **๐ ๋ฒกํฐ ๊ฒ์**: FAISS ๊ธฐ๋ฐ ๊ณ ์ ์ ์ฌ๋ ๊ฒ์
- **๐ ๋ฌธ์ ์ฒ๋ฆฌ**: PDF, DOCX, TXT ๋ฑ ๋ค์ํ ๋ฌธ์ ํ์ ์ง์
- **๐ผ๏ธ ์ด๋ฏธ์ง OCR**: LaTeX-OCR์ ํตํ ์ํ ๊ณต์ ์ธ์
- **โก ๋น๋๊ธฐ ์ฒ๋ฆฌ**: Celery ๊ธฐ๋ฐ ๋ฐฑ๊ทธ๋ผ์ด๋ ์์
- **๐ RESTful API**: FastAPI ๊ธฐ๋ฐ ๊ณ ์ฑ๋ฅ ์น API
### ๐ ์ฌ์ฉ ๋ฐฉ๋ฒ
#### 1. ํ
์คํธ ์์ฑ
```python
import requests
response = requests.post(
"https://your-space-url/generate",
data={"prompt": "์๋
ํ์ธ์! ์ค๋ ๋ ์จ๊ฐ ์ด๋ค๊ฐ์?"}
)
print(response.json())
```
#### 2. ์ด๋ฏธ์ง์ ํจ๊ป ์ง์
```python
import requests
with open("image.jpg", "rb") as f:
response = requests.post(
"https://your-space-url/generate",
data={"prompt": "์ด๋ฏธ์ง์์ ๋ฌด์์ ๋ณผ ์ ์๋์?"},
files={"image1": f}
)
print(response.json())
```
#### 3. RAG ๊ธฐ๋ฐ ์ง์์๋ต
```python
import requests
# ๋ฌธ์ ์
๋ก๋
with open("document.pdf", "rb") as f:
upload_response = requests.post(
"https://your-space-url/upload-document",
files={"file": f},
data={"user_id": "your_user_id"}
)
document_id = upload_response.json()["document_id"]
# RAG ์ง์
response = requests.post(
"https://your-space-url/rag-query",
json={
"query": "๋ฌธ์์ ์ฃผ์ ๋ด์ฉ์ ๋ฌด์์ธ๊ฐ์?",
"user_id": "your_user_id",
"document_id": document_id
}
)
print(response.json())
```
### ๐ API ์๋ํฌ์ธํธ
#### ๊ธฐ๋ณธ ์๋ํฌ์ธํธ
- `GET /health` - ์๋ฒ ์ํ ํ์ธ
- `GET /models` - ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ธ ๋ชฉ๋ก
- `POST /load-model` - ๋ชจ๋ธ ๋ก๋
- `POST /generate` - ํ
์คํธ/์ด๋ฏธ์ง ์์ฑ
#### RAG ์์คํ
- `POST /upload-document` - ๋ฌธ์ ์
๋ก๋
- `POST /rag-query` - RAG ๊ธฐ๋ฐ ์ง์
- `GET /documents/{user_id}` - ์ฌ์ฉ์ ๋ฌธ์ ๋ชฉ๋ก
- `DELETE /document/{document_id}` - ๋ฌธ์ ์ญ์
#### ๊ณ ๊ธ ๊ธฐ๋ฅ
- `POST /batch-process` - ๋ฐฐ์น ๋ฌธ์ ์ฒ๋ฆฌ
- `GET /task-status/{task_id}` - ์์
์ํ ํ์ธ
- `POST /cancel-task/{task_id}` - ์์
์ทจ์
### ๐ ๏ธ ๊ธฐ์ ์คํ
- **Backend**: FastAPI, Python 3.11
- **AI Models**: Transformers, PyTorch
- **Vector DB**: FAISS, ChromaDB
- **Task Queue**: Celery, Redis
- **OCR**: LaTeX-OCR, EasyOCR
- **Document Processing**: LangChain
### ๐ ๋ชจ๋ธ ์ ๋ณด
#### Kanana-1.5-v-3b-instruct
- **ํฌ๊ธฐ**: 3.6B ๋งค๊ฐ๋ณ์
- **์ธ์ด**: ํ๊ตญ์ด ํนํ
- **๊ธฐ๋ฅ**: ํ
์คํธ ์์ฑ, ์ด๋ฏธ์ง ์ดํด
- **์ปจํ
์คํธ**: ์ต๋ 4096 ํ ํฐ
### ๐ง ์ค์
ํ๊ฒฝ ๋ณ์๋ฅผ ํตํด ๋ค์ ์ค์ ์ ์กฐ์ ํ ์ ์์ต๋๋ค:
```bash
# ์๋ฒ ์ค์
HOST=0.0.0.0
PORT=7860
# ๋ชจ๋ธ ์ค์
DEFAULT_MODEL=kanana-1.5-v-3b-instruct
MAX_NEW_TOKENS=256
TEMPERATURE=0.7
# ์บ์ ์ค์
TRANSFORMERS_CACHE=/app/cache/transformers
HF_HOME=/app/cache/huggingface
```
### ๐ ๋ผ์ด์ ์ค
์ด ํ๋ก์ ํธ๋ MIT ๋ผ์ด์ ์ค ํ์ ๋ฐฐํฌ๋ฉ๋๋ค.
### ๐ค ๊ธฐ์ฌ
๋ฒ๊ทธ ๋ฆฌํฌํธ, ๊ธฐ๋ฅ ์ ์, ํ ๋ฆฌํ์คํธ๋ฅผ ํ์ํฉ๋๋ค!
### ๐ ์ง์
๋ฌธ์์ฌํญ์ด ์์ผ์๋ฉด GitHub Issues๋ฅผ ํตํด ์ฐ๋ฝํด ์ฃผ์ธ์. |