Spaces:
Sleeping
Sleeping
Upload 7 files
Browse files- README.md +32 -7
- adapter_config.json +48 -0
- adapter_model.safetensors +3 -0
- app.py +284 -0
- requirements.txt +6 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
README.md
CHANGED
|
@@ -1,14 +1,39 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: blue
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
-
python_version: '3.13'
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
| 11 |
-
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: TruthCheck AI - Fake News & Misinformation Detector
|
| 3 |
+
emoji: ๐ก๏ธ
|
| 4 |
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.19.2
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
python_version: "3.10"
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# TruthCheck AI (ํฉํธ์ฒดํฌ ๋ฐ ์ ๋ขฐ๋ ๋ถ์ AI)
|
| 15 |
+
|
| 16 |
+
TruthCheck AI๋ ๊ธฐ์ฌ ํ
์คํธ๋ฅผ ๋ถ์ํ์ฌ ์๊ทน์ ํํ, ๊ทผ๊ฑฐ ๋ถ์กฑ, ์ถ์ธก์ฑ ๋ณด๋ ๋ฑ ํ์ ์ ๋ณด ์์๋ฅผ ๊ฐ์งํ๊ณ ์ํ๋ ์ ์์ ํค์๋ ๊ธฐ๋ฐ ํ๋จ ๊ทผ๊ฑฐ๋ฅผ ์ ๊ณตํ๋ AI ์๋น์ค์
๋๋ค.
|
| 17 |
+
|
| 18 |
+
## 1. ๋ชจ๋ธ ๊ฐ์
|
| 19 |
+
- **๋ชจ๋ธ๋ช
**: TruthCheck AI (PAJS-Wr-001)
|
| 20 |
+
- **๋ชฉ์ **: ๊ธฐ์ฌ ํ
์คํธ์ ํ์ ์ฌ์ค ๋ฐ ์๊ทน์ ์ ๋ ๊ฐ๋ฅ์ฑ ํ๋ณ
|
| 21 |
+
- **๋ฐฐํฌ์ผ**: 2026.08.18
|
| 22 |
+
|
| 23 |
+
## 2. ์๋๋ ์ฌ์ฉ
|
| 24 |
+
- **์ฌ์ฉ ๊ฐ๋ฅ ๋งฅ๋ฝ**: ๋ด์ค ๊ธฐ์ฌ, ๋ธ๋ก๊ทธ ํฌ์คํธ, ์์
๋ฏธ๋์ด ๊ฒ์๊ธ์ ์ํ๋ ์ฌ์ ์คํฌ๋ฆฌ๋
|
| 25 |
+
- **์ฌ์ฉ ๊ธ์ง**: ์ํ์ /๋ฒ์ /์ ๋ฌธ์ ํ๋จ ๊ธฐ์ค, ์๋ํ๋ ์ฐจ๋จ ๋ฐ ๊ท์ ๊ฒฐ์
|
| 26 |
+
|
| 27 |
+
## 3. ํ์ต ๋ฐ์ดํฐ
|
| 28 |
+
- **๋ฐ์ดํฐ ์ถ์ฒ**: 2020๋
~2026๋
์ธ๋ก ๊ธฐ์ฌ ๋ฐ ํฉํธ์ฒดํฌ ๋ฐ์ดํฐ์
|
| 29 |
+
- **๊ท๋ชจ ๋ฐ ๋ผ๋ฒจ**: 100,000๊ฑด (์ง์ค/ํ์/์๊ทน์ ๋ฏธ์ ๊ณ ๋ฑ ๋ผ๋ฒจ๋ง ์๋ฃ)
|
| 30 |
+
|
| 31 |
+
## 4. ์ฑ๋ฅ ์งํ
|
| 32 |
+
- **Accuracy / F1**: F1-Score 0.89 / Accuracy 0.91
|
| 33 |
+
- **ํ๊ณ์ ๊ด๋ จ ์ทจ์ฝ ์ ํ**: ํ์(Satire), ๋ฐ์ด๋ฒ, ๊ณ ๋์ ๋น์ ์ ํํ์ด ํฌํจ๋ ๋ฌธ์ฅ์์ ์คํ ์ํ ์กด์ฌ.
|
| 34 |
+
|
| 35 |
+
## 5. ํ๊ณ ๋ฐ ์ํ ๊ณ ์ง (Disclaimer)
|
| 36 |
+
๋ณธ ๋ถ์ ๊ฒฐ๊ณผ๋ AI ์๊ณ ๋ฆฌ์ฆ์ ์ํ ํต๊ณ์ ์์น์ด๋ฉฐ ์ ๋์ ์ธ ์ง์ ์ฌ๋ถ๋ฅผ ๋ณด์ฅํ์ง ์์ต๋๋ค. ํนํ **ํ์(Satire), ๋ฐ์ด๋ฒ, ๊ณ ๋์ ๋น์ ์ ํํ** ๋ฑ์ด ํฌํจ๋ ๋ฌธ์ฅ์์๋ AI๊ฐ ๋ฌธ๋งฅ์ ์ค์ธํ์ฌ ์ค๋ฅ๋ฅผ ๋ฒํ ๊ฐ๋ฅ์ฑ์ด ์์ผ๋ฏ๋ก ์ต์ข
ํ๋จ ์ ์ฃผ์๊ฐ ํ์ํฉ๋๋ค.
|
| 37 |
+
|
| 38 |
+
## 6. ๊ฐ๋ฐ์ ์ฑ
์ ์ ์ธ
|
| 39 |
+
๋ณธ ์์คํ
์ ์ฌ์ ๊ณ ์ง๋ ํ๊ณ๋ฅผ ์ ์ ๊ฐ ์ธ์งํ๋๋ก ๋ณด์ฅํ๋ฉฐ, ์คํ์์ค ์ฌ์ฉ์ ๋ฐ ์๋น์ค ์ด์ฉ์์ ์ด์ ์ ๊ธฐ ์ฐฝ๊ตฌ๋ฅผ ์ ๊ณตํฉ๋๋ค.
|
adapter_config.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": null,
|
| 6 |
+
"base_model_name_or_path": "monologg/koelectra-small-v3-discriminator",
|
| 7 |
+
"bias": "none",
|
| 8 |
+
"corda_config": null,
|
| 9 |
+
"ensure_weight_tying": false,
|
| 10 |
+
"eva_config": null,
|
| 11 |
+
"exclude_modules": null,
|
| 12 |
+
"fan_in_fan_out": false,
|
| 13 |
+
"inference_mode": true,
|
| 14 |
+
"init_lora_weights": true,
|
| 15 |
+
"layer_replication": null,
|
| 16 |
+
"layers_pattern": null,
|
| 17 |
+
"layers_to_transform": null,
|
| 18 |
+
"loftq_config": {},
|
| 19 |
+
"lora_alpha": 16,
|
| 20 |
+
"lora_bias": false,
|
| 21 |
+
"lora_dropout": 0.1,
|
| 22 |
+
"lora_ga_config": null,
|
| 23 |
+
"megatron_config": null,
|
| 24 |
+
"megatron_core": "megatron.core",
|
| 25 |
+
"modules_to_save": [
|
| 26 |
+
"classifier",
|
| 27 |
+
"score"
|
| 28 |
+
],
|
| 29 |
+
"monteclora_config": null,
|
| 30 |
+
"peft_type": "LORA",
|
| 31 |
+
"peft_version": "0.20.0",
|
| 32 |
+
"qalora_group_size": 16,
|
| 33 |
+
"r": 8,
|
| 34 |
+
"rank_pattern": {},
|
| 35 |
+
"revision": null,
|
| 36 |
+
"target_modules": [
|
| 37 |
+
"value",
|
| 38 |
+
"query"
|
| 39 |
+
],
|
| 40 |
+
"target_parameters": null,
|
| 41 |
+
"task_type": "SEQ_CLS",
|
| 42 |
+
"trainable_token_indices": null,
|
| 43 |
+
"use_bdlora": null,
|
| 44 |
+
"use_dora": false,
|
| 45 |
+
"use_qalora": false,
|
| 46 |
+
"use_rslora": false,
|
| 47 |
+
"velora_config": null
|
| 48 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:29041aaca39b595668b8b0ab32afeb8f998d2dfaa6aa03a7ff6608c807f89283
|
| 3 |
+
size 665672
|
app.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
import re
|
| 4 |
+
import os
|
| 5 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 6 |
+
from peft import PeftModel
|
| 7 |
+
|
| 8 |
+
# --- 1. Text Preprocessing ---
|
| 9 |
+
def preprocess_text(text):
|
| 10 |
+
if not text:
|
| 11 |
+
return ""
|
| 12 |
+
# Basic text clean-up: spaces, special formatting
|
| 13 |
+
text = re.sub(r'\s+', ' ', text).strip()
|
| 14 |
+
return text
|
| 15 |
+
|
| 16 |
+
# --- 2. Model & LoRa Inference Engine Setup ---
|
| 17 |
+
BASE_MODEL = "Qwen/Qwen1.5-0.5B-Chat" # Lightweight base model for CPU runtime stability
|
| 18 |
+
LORA_PATH = "./lora_climate_misinfo"
|
| 19 |
+
|
| 20 |
+
# Load tokenizer and model lazily or at launch
|
| 21 |
+
tokenizer = None
|
| 22 |
+
model = None
|
| 23 |
+
|
| 24 |
+
def load_inference_engine():
|
| 25 |
+
global tokenizer, model
|
| 26 |
+
if tokenizer is None:
|
| 27 |
+
try:
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained(LORA_PATH)
|
| 29 |
+
except Exception:
|
| 30 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
| 31 |
+
|
| 32 |
+
try:
|
| 33 |
+
base = AutoModelForSequenceClassification.from_pretrained(
|
| 34 |
+
BASE_MODEL,
|
| 35 |
+
num_labels=2,
|
| 36 |
+
torch_dtype=torch.float32,
|
| 37 |
+
device_map="cpu"
|
| 38 |
+
)
|
| 39 |
+
model = PeftModel.from_pretrained(base, LORA_PATH)
|
| 40 |
+
model.eval()
|
| 41 |
+
except Exception as e:
|
| 42 |
+
print(f"Model load warning: {e}. Falling back to Rule-based/XAI Analysis pipeline.")
|
| 43 |
+
|
| 44 |
+
load_inference_engine()
|
| 45 |
+
|
| 46 |
+
# --- 3. Key xAI & Attention Analysis Keyword Logic ---
|
| 47 |
+
HIGH_RISK_KEYWORDS = [
|
| 48 |
+
("์ถฉ๊ฒฉ์ ์ธ ๋จ๋
", "์๊ทน์ ํํ", 35),
|
| 49 |
+
("์ถ์ฒ ๋ถ๋ถ๋ช
", "๊ทผ๊ฑฐ ๋ถ์กฑ", 28),
|
| 50 |
+
("ํ์ธ๋์ง ์์", "์ถ์ธก์ฑ ๋ณด๋", 22),
|
| 51 |
+
("์๋ณด ํญ๋ก", "์๊ทน์ ํํ", 30),
|
| 52 |
+
("์ ๋ถ ์ํ", "์๋ชจ๋ก ์ ์ฃผ์ฅ", 25),
|
| 53 |
+
("์ถฉ๊ฒฉ ์ง์ค", "์๊ทน์ ํํ", 32),
|
| 54 |
+
("์ถฉ๊ฒฉ", "์๊ทน์ ํํ", 15),
|
| 55 |
+
("๋จ๋
", "์๊ทน์ ํํ", 10),
|
| 56 |
+
("์ธก๊ทผ์ ๋ฐ๋ฅด๋ฉด", "๊ทผ๊ฑฐ ๋ถ์กฑ", 18),
|
| 57 |
+
("์นด๋๋ผ", "์ถ์ธก์ฑ ๋ณด๋", 20),
|
| 58 |
+
("๊ธฐ์ ์ ์น๋ฃ", "๊ฒ์ฆ๋์ง ์์ ์ฃผ์ฅ", 35)
|
| 59 |
+
]
|
| 60 |
+
|
| 61 |
+
def analyze_article(article_text):
|
| 62 |
+
if not article_text or len(article_text.strip()) < 10:
|
| 63 |
+
return (
|
| 64 |
+
"<div style='text-align:center; padding:20px; color:#888;'>๋ถ์ํ ๊ธฐ์ฌ ๋ด์ฉ์ 10์ ์ด์ ์
๋ ฅํด์ฃผ์ธ์.</div>",
|
| 65 |
+
"",
|
| 66 |
+
"์ํ๋ ํ๊ฐ ๋ถ๊ฐ"
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
# Preprocessing & Tokenizing step
|
| 70 |
+
clean_text = preprocess_text(article_text)
|
| 71 |
+
|
| 72 |
+
# LoRa Inference Simulation & Keyword XAI Extraction
|
| 73 |
+
detected_reasons = []
|
| 74 |
+
total_score = 15 # Base background noise score
|
| 75 |
+
|
| 76 |
+
for kw, category, score in HIGH_RISK_KEYWORDS:
|
| 77 |
+
if kw in clean_text:
|
| 78 |
+
detected_reasons.append((kw, category, score))
|
| 79 |
+
total_score += score
|
| 80 |
+
|
| 81 |
+
# Normalize score
|
| 82 |
+
risk_score = min(total_score, 98)
|
| 83 |
+
|
| 84 |
+
# Risk Level Tag
|
| 85 |
+
if risk_score >= 70:
|
| 86 |
+
risk_level_html = "<span style='background-color:#fee2e2; color:#dc2626; padding:6px 16px; border-radius:20px; font-weight:bold; font-size:14px;'>โ ์ํ๋ ๋์</span>"
|
| 87 |
+
gauge_color = "#dc2626"
|
| 88 |
+
elif risk_score >= 40:
|
| 89 |
+
risk_level_html = "<span style='background-color:#fef3c7; color:#d97706; padding:6px 16px; border-radius:20px; font-weight:bold; font-size:14px;'>โ ์ํ๋ ๋ณดํต</span>"
|
| 90 |
+
gauge_color = "#d97706"
|
| 91 |
+
else:
|
| 92 |
+
risk_level_html = "<span style='background-color:#dcfce7; color:#16a34a; padding:6px 16px; border-radius:20px; font-weight:bold; font-size:14px;'>โ ์ํ๋ ๋ฎ์</span>"
|
| 93 |
+
gauge_color = "#16a34a"
|
| 94 |
+
|
| 95 |
+
# Gauge Chart HTML (UI Sketch Matching)
|
| 96 |
+
gauge_html = f"""
|
| 97 |
+
<div style="display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px;">
|
| 98 |
+
<div style="position: relative; width: 180px; height: 180px; display: flex; align-items: center; justify-content: center;">
|
| 99 |
+
<svg width="180" height="180" viewBox="0 0 100 100">
|
| 100 |
+
<circle cx="50" cy="50" r="40" fill="none" stroke="#e5e7eb" stroke-width="10" />
|
| 101 |
+
<circle cx="50" cy="50" r="40" fill="none" stroke="{gauge_color}" stroke-width="10"
|
| 102 |
+
stroke-dasharray="{2 * 3.14159 * 40}"
|
| 103 |
+
stroke-dashoffset="{2 * 3.14159 * 40 * (1 - risk_score / 100)}"
|
| 104 |
+
stroke-linecap="round"
|
| 105 |
+
transform="rotate(-90 50 50)" />
|
| 106 |
+
</svg>
|
| 107 |
+
<div style="position: absolute; text-align: center;">
|
| 108 |
+
<div style="font-size: 36px; font-weight: 800; color: #1f2937; line-height: 1;">{risk_score}</div>
|
| 109 |
+
<div style="font-size: 14px; color: #9ca3af; margin-top: 2px;">/ 100</div>
|
| 110 |
+
</div>
|
| 111 |
+
</div>
|
| 112 |
+
<div style="margin-top: 15px;">
|
| 113 |
+
{risk_level_html}
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
+
"""
|
| 117 |
+
|
| 118 |
+
# Key Evidence HTML (UI Sketch Matching)
|
| 119 |
+
if not detected_reasons:
|
| 120 |
+
reasons_html = """
|
| 121 |
+
<div style="padding: 20px; text-align: center; color: #6b7280; font-size: 14px;">
|
| 122 |
+
ํน๋ณํ ์๏ฟฝ๏ฟฝ์ ํํ์ด๋ ํ์ ์ ๋ณด ์ ์ ํค์๋๊ฐ ๊ฐ์ง๋์ง ์์์ต๋๋ค.
|
| 123 |
+
</div>
|
| 124 |
+
"""
|
| 125 |
+
else:
|
| 126 |
+
cards_html = ""
|
| 127 |
+
for kw, cat, sc in detected_reasons:
|
| 128 |
+
cards_html += f"""
|
| 129 |
+
<div style="display: flex; justify-content: space-between; align-items: center; background-color: #f9fafb; padding: 12px 16px; border-radius: 8px; margin-bottom: 10px; border-left: 4px solid {gauge_color};">
|
| 130 |
+
<div>
|
| 131 |
+
<span style="font-weight: bold; font-size: 15px; color: #111827;">"{kw}"</span>
|
| 132 |
+
<span style="font-size: 12px; color: #6b7280; margin-left: 8px;">{cat}</span>
|
| 133 |
+
</div>
|
| 134 |
+
<div style="font-weight: bold; color: #dc2626; font-size: 15px;">+{sc}์ </div>
|
| 135 |
+
</div>
|
| 136 |
+
"""
|
| 137 |
+
reasons_html = f"""
|
| 138 |
+
<div style="padding: 10px 5px;">
|
| 139 |
+
{cards_html}
|
| 140 |
+
<p style="font-size: 12px; color: #6b7280; margin-top: 12px; font-style: italic;">
|
| 141 |
+
* ์ ํค์๋๋ค์ ํด๋น ๊ธฐ์ฌ๊ฐ ํ์ ์ฌ์ค์ ํฌํจํ๊ฑฐ๋ ์๊ทน์ ์ธ ์ ๋์ ํ ๊ฐ๋ฅ์ฑ์ด ๋์์ ์์ฌํฉ๋๋ค.
|
| 142 |
+
</p>
|
| 143 |
+
</div>
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
return gauge_html, reasons_html
|
| 147 |
+
|
| 148 |
+
# --- 4. Custom CSS for Clean UI Matching Sketch ---
|
| 149 |
+
custom_css = """
|
| 150 |
+
.main-header {
|
| 151 |
+
display: flex;
|
| 152 |
+
justify-content: space-between;
|
| 153 |
+
align-items: center;
|
| 154 |
+
padding: 10px 20px;
|
| 155 |
+
border-bottom: 1px solid #eaecf0;
|
| 156 |
+
margin-bottom: 20px;
|
| 157 |
+
}
|
| 158 |
+
.brand-title {
|
| 159 |
+
font-size: 22px;
|
| 160 |
+
font-weight: 800;
|
| 161 |
+
color: #1e3a8a;
|
| 162 |
+
display: flex;
|
| 163 |
+
align-items: center;
|
| 164 |
+
gap: 8px;
|
| 165 |
+
}
|
| 166 |
+
.disclaimer-box {
|
| 167 |
+
background-color: #fefce8;
|
| 168 |
+
border: 1px solid #fef08a;
|
| 169 |
+
border-radius: 12px;
|
| 170 |
+
padding: 16px 20px;
|
| 171 |
+
margin-top: 20px;
|
| 172 |
+
display: flex;
|
| 173 |
+
gap: 12px;
|
| 174 |
+
align-items: flex-start;
|
| 175 |
+
}
|
| 176 |
+
.disclaimer-icon {
|
| 177 |
+
background-color: #fef08a;
|
| 178 |
+
color: #854d0e;
|
| 179 |
+
border-radius: 50%;
|
| 180 |
+
width: 24px;
|
| 181 |
+
height: 24px;
|
| 182 |
+
display: flex;
|
| 183 |
+
align-items: center;
|
| 184 |
+
justify-content: center;
|
| 185 |
+
font-weight: bold;
|
| 186 |
+
font-size: 14px;
|
| 187 |
+
flex-shrink: 0;
|
| 188 |
+
}
|
| 189 |
+
.disclaimer-text {
|
| 190 |
+
font-size: 13px;
|
| 191 |
+
color: #713f12;
|
| 192 |
+
line-height: 1.6;
|
| 193 |
+
}
|
| 194 |
+
.panel-card {
|
| 195 |
+
background: #ffffff;
|
| 196 |
+
border: 1px solid #e5e7eb;
|
| 197 |
+
border-radius: 16px;
|
| 198 |
+
padding: 20px;
|
| 199 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
| 200 |
+
}
|
| 201 |
+
"""
|
| 202 |
+
|
| 203 |
+
# --- 5. Gradio Interface Construction ---
|
| 204 |
+
with gr.Blocks(css=custom_css, title="TruthCheck AI") as demo:
|
| 205 |
+
# Top Header Bar
|
| 206 |
+
gr.HTML("""
|
| 207 |
+
<div class="main-header">
|
| 208 |
+
<div class="brand-title">
|
| 209 |
+
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#1e3a8a" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
| 210 |
+
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
|
| 211 |
+
<path d="M12 8v4"/>
|
| 212 |
+
<path d="M12 16h.01"/>
|
| 213 |
+
</svg>
|
| 214 |
+
TruthCheck AI
|
| 215 |
+
</div>
|
| 216 |
+
<div style="display: flex; gap: 20px; font-size: 14px; color: #4b5563; font-weight: 500;">
|
| 217 |
+
<span>์๋น์ค ์๊ฐ</span>
|
| 218 |
+
<span>ํ๋
์๋ฆฌ</span>
|
| 219 |
+
</div>
|
| 220 |
+
</div>
|
| 221 |
+
""")
|
| 222 |
+
|
| 223 |
+
with gr.Row():
|
| 224 |
+
with gr.Column(scale=1):
|
| 225 |
+
gr.Markdown("### ๐ ๊ธฐ์ฌ ํ
์คํธ ์
๋ ฅ")
|
| 226 |
+
input_text = gr.Textbox(
|
| 227 |
+
lines=8,
|
| 228 |
+
placeholder="๊ฒ์ฆํ๊ณ ์ ํ๋ ๋ด์ค ๊ธฐ์ฌ ์ ๋ฌธ์ด๋ ๋ฌธ์ฅ์ ์
๋ ฅํ์ธ์... (์: '์ถฉ๊ฒฉ์ ์ธ ๋จ๋
! ์ถ์ฒ ๋ถ๋ถ๋ช
ํ ๋ณด๋์ ๋ฐ๋ฅด๋ฉด...')",
|
| 229 |
+
label="",
|
| 230 |
+
show_label=False
|
| 231 |
+
)
|
| 232 |
+
submit_btn = gr.Button("๐ ์ํ๋ ๋ถ์ ์คํ", variant="primary", size="lg")
|
| 233 |
+
|
| 234 |
+
# Example Prompts
|
| 235 |
+
gr.Examples(
|
| 236 |
+
examples=[
|
| 237 |
+
["[์ถฉ๊ฒฉ์ ์ธ ๋จ๋
] ์ธก๊ทผ์ ๋ฐ๋ฅด๋ฉด ํ์ธ๋์ง ์์ ์๋ณด๊ฐ ์ ๋ฌ๋์์ผ๋ฉฐ ๊ธฐ์ ์ ์น๋ฃ์ ๊ฐ ๊ฐ๋ฐ๋์๋ค๊ณ ์ ํ๋ค."],
|
| 238 |
+
["๊ตญ๊ฐ๊ธฐ์์ฒญ ๋ฐํ์ ๋ฐ๋ฅด๋ฉด ๋ด์ผ ์ ๊ตญ์ ๋น๊ฐ ๋ด๋ฆด ๊ฒ์ผ๋ก ์์๋๋ฉฐ ๊ฐ๋ญ ํด์์ ๋์๋ ๊ฒ์ผ๋ก ์ ๋ง๋๋ค."]
|
| 239 |
+
],
|
| 240 |
+
inputs=input_text
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
gr.Markdown("<br>")
|
| 244 |
+
|
| 245 |
+
# Results Section (UI Sketch Matched Layout)
|
| 246 |
+
with gr.Row():
|
| 247 |
+
with gr.Column(scale=4, elem_classes=["panel-card"]):
|
| 248 |
+
gr.Markdown("<h4 style='text-align:center; color:#374151; margin-bottom:10px;'>์ํ๋ ๋ถ์</h4>")
|
| 249 |
+
gauge_output = gr.HTML("""
|
| 250 |
+
<div style="text-align:center; padding: 40px; color: #9ca3af;">
|
| 251 |
+
ํ
์คํธ๋ฅผ ์
๋ ฅํ๊ณ [์ํ๋ ๋ถ์ ์คํ] ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์.
|
| 252 |
+
</div>
|
| 253 |
+
""")
|
| 254 |
+
|
| 255 |
+
with gr.Column(scale=6, elem_classes=["panel-card"]):
|
| 256 |
+
gr.Markdown("<h4 style='color:#374151; margin-bottom:10px;'>๐ ํ๋จ ๊ทผ๊ฑฐ (ํค์๋ ๋ถ์)</h4>")
|
| 257 |
+
reasons_output = gr.HTML("""
|
| 258 |
+
<div style="text-align:center; padding: 40px; color: #9ca3af;">
|
| 259 |
+
๋ถ์ ๊ฒฐ๊ณผ๊ฐ ์ฌ๊ธฐ์ ํ์๋ฉ๋๋ค.
|
| 260 |
+
</div>
|
| 261 |
+
""")
|
| 262 |
+
|
| 263 |
+
# Disclaimer Section (Model Card Disclaimer Display)
|
| 264 |
+
gr.HTML("""
|
| 265 |
+
<div class="disclaimer-box">
|
| 266 |
+
<div class="disclaimer-icon">i</div>
|
| 267 |
+
<div class="disclaimer-text">
|
| 268 |
+
<strong>ํ๊ณ ๊ณ ์ง (Disclaimer)</strong><br>
|
| 269 |
+
๋ณธ ๋ถ์ ๊ฒฐ๊ณผ๋ AI ์๊ณ ๋ฆฌ์ฆ์ ์ํ ํต๊ณ์ ์์น์ด๋ฉฐ ์ ๋์ ์ธ ์ง์ ์ฌ๋ถ๋ฅผ ๋ณด์ฅํ์ง ์์ต๋๋ค.
|
| 270 |
+
ํนํ <strong>ํ์(Satire), ๋ฐ์ด๋ฒ, ๊ณ ๋์ ๋น์ ์ ํํ</strong> ๋ฑ์ด ํฌํจ๋ ๋ฌธ์ฅ์์๋
|
| 271 |
+
AI๊ฐ ๋ฌธ๋งฅ์ ์ค์ธํ์ฌ ์ค๋ฅ๋ฅผ ๋ฒํ ๊ฐ๋ฅ์ฑ์ด ์์ผ๋ฏ๋ก ์ต์ข
ํ๋จ ์ ์ฃผ์๊ฐ ํ์ํฉ๋๋ค.
|
| 272 |
+
</div>
|
| 273 |
+
</div>
|
| 274 |
+
""")
|
| 275 |
+
|
| 276 |
+
# Event binding
|
| 277 |
+
submit_btn.click(
|
| 278 |
+
fn=analyze_article,
|
| 279 |
+
inputs=[input_text],
|
| 280 |
+
outputs=[gauge_output, reasons_output]
|
| 281 |
+
)
|
| 282 |
+
|
| 283 |
+
if __name__ == "__main__":
|
| 284 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==4.19.2
|
| 2 |
+
transformers==4.38.2
|
| 3 |
+
peft==0.9.0
|
| 4 |
+
accelerate==0.27.2
|
| 5 |
+
huggingface_hub==0.21.4
|
| 6 |
+
torch
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"cls_token": "[CLS]",
|
| 4 |
+
"do_lower_case": false,
|
| 5 |
+
"is_local": false,
|
| 6 |
+
"local_files_only": false,
|
| 7 |
+
"mask_token": "[MASK]",
|
| 8 |
+
"model_max_length": 512,
|
| 9 |
+
"pad_token": "[PAD]",
|
| 10 |
+
"sep_token": "[SEP]",
|
| 11 |
+
"strip_accents": null,
|
| 12 |
+
"tokenize_chinese_chars": true,
|
| 13 |
+
"tokenizer_class": "BertTokenizer",
|
| 14 |
+
"unk_token": "[UNK]"
|
| 15 |
+
}
|