Dusit-P commited on
Commit
5c19a4d
·
verified ·
1 Parent(s): f1214c8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -0
README.md CHANGED
@@ -171,4 +171,71 @@ def classify(text: str):
171
 
172
  print(classify("บริการดีมาก ประทับใจ"))
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
 
 
 
 
 
 
 
 
 
171
 
172
  print(classify("บริการดีมาก ประทับใจ"))
173
 
174
+ ---
175
+ Space / REST API
176
+ Base URL: https://<YOUR_SPACE_URL>
177
+ API ด้านล่างอ้างอิงฟังก์ชันใน app.py ของ Space: predict_one, predict_many, predict_csv
178
+ หากคุณเปลี่ยนชื่อฟังก์ชัน/เส้นทาง ให้ปรับ URL ให้สอดคล้อง
179
+ 1) Predict ข้อความเดียว
180
+ POST /run/predict_one
181
+ Body (JSON):
182
+ {
183
+ "data": ["อาหารอร่อยมาก บริการดี", "cnn_bilstm"]
184
+ }
185
+
186
+ -Response (ตัวอย่าง):
187
+ {
188
+ "data": [
189
+ {"negative": 0.12, "positive": 0.88},
190
+ "positive"
191
+ ]
192
+ }
193
+
194
+ -curl ตัวอย่าง:
195
+ curl -X POST "https://<YOUR_SPACE_URL>/run/predict_one" \
196
+ -H "content-type: application/json" \
197
+ -d '{"data":["อาหารอร่อยมาก บริการดี","cnn_bilstm"]}'
198
+
199
+ 2) Predict หลายข้อความ (ทีละบรรทัด)
200
+ POST /run/predict_many
201
+ Body (JSON):
202
+ {
203
+ "data": ["แย่มาก รอนานมาก\nอร่อย บริการไว", "cnn_bilstm"]
204
+ }
205
+
206
+ -curl ตัวอย่าง:
207
+ curl -X POST "https://<YOUR_SPACE_URL>/run/predict_many" \
208
+ -H "content-type: application/json" \
209
+ -d '{"data":["แย่มาก รอนานมาก\nอร่อย บริการไว","cnn_bilstm"]}'
210
+
211
+ 3) อัปโหลด CSV
212
+ POST /run/predict_csv (multipart/form-data)
213
+ Fields
214
+ file: ไฟล์ CSV (ต้องมีคอลัมน์ review; ถ้ามี shop จะแสดงสรุปต่อร้าน)
215
+ model_choice: cnn_bilstm | baseline | last4weighted_bilstm
216
+ curl ตัวอย่าง:
217
+
218
+ curl -X POST "https://<YOUR_SPACE_URL>/run/predict_csv" \
219
+ -F "file=@/path/to/reviews.csv" \
220
+ -F "model_choice=cnn_bilstm"
221
+
222
+ >บางเวอร์ชันของ Gradio มีปุ่ม “View API” บนหน้า Space เพื่อตรวจ schema/endpoint ล่าสุดอัตโนมัติ
223
+ ---
224
+ #Reproducibility (ย่อ)
225
+ -Base: airesearch/wangchanberta-base-att-spm-uncased
226
+ -max_len=128, Batch size=16, Optimizer: AdamW (lr_bert=2e-5, lr_others=1e-3), Early stopping
227
+ -5-Fold Stratified, Seed=42
228
+ -ไลบรารีหลัก: torch, transformers, safetensors, sentencepiece
229
+ ---
230
+ #License & Attribution
231
+ >Model license: MIT (ปรับได้ตามต้องการ)
232
+ >Dataset: Wisesight Sentiment — โปรดอ้างอิงและปฏิบัติตามสัญญาอนุญาตของชุดข้อมูลต้นทาง
233
 
234
+ ---
235
+ #Citation
236
+ >Dusit P. (2025). Thai Sentiment WCB (WangchanBERTa + LSTM/CNN/Last4 heads).
237
+ >Hugging Face: Dusit-P/thai-sentiment-wcb.
238
+ >Demo: <https://<YOUR_SPACE_URL>>.
239
+ ---
240
+ #Changelog
241
+ -v1.0.0 — ปล่อย cnn_bilstm, baseline, last4weighted_bilstm; เพิ่ม Space (UI/REST)