Przeglądaj źródła

修复模型回复截断问题和数据集预览问题

lxylxy123321 1 tydzień temu
rodzic
commit
156547a7c3

+ 2 - 0
backend/app/services/dataset_service.py

@@ -22,6 +22,8 @@ META_FILENAMES = frozenset({
     "special_tokens_map.json", "tokenizer_config.json",
     "added_tokens.json", "vocab.json", "merges.txt",
     "config.json", "preprocessor_config.json",
+    "dataset_infos.json", "dataset_info.json",
+    "state.json", "card_data.json",
 })
 
 # File size threshold: files smaller than this (bytes) are likely metadata

+ 12 - 2
backend/app/services/model_test_service.py

@@ -85,6 +85,16 @@ if model_path is None:
     print(json.dumps({{'error': f'Model not found in cache: {{model_id}}'}}))
     exit(1)
 
+# 抑制模型加载时的调试输出(Qwen3.5 等模型会直接 print 到 stdout)
+_original_stdout = sys.stdout
+
+class _SilentStdout:
+    def write(self, *args, **kwargs):
+        pass
+    def flush(self, *args, **kwargs):
+        pass
+
+sys.stdout = _SilentStdout()
 t = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
 t.pad_token = t.pad_token or t.eos_token
 
@@ -104,10 +114,8 @@ for cls, kw in [(AutoModelForCausalLM, {{'trust_remote_code': True}}), (AutoMode
     for dtype_val, dtype_name in [(torch.float16, 'float16'), (torch.float32, 'float32')]:
         try:
             if has_accelerate:
-                # 有 accelerate,用 device_map='auto' 自动分配
                 m = cls.from_pretrained(model_path, dtype=dtype_val, device_map='auto', **kw)
             else:
-                # 没有 accelerate,手动加载到单卡
                 m = cls.from_pretrained(model_path, dtype=dtype_val, device_map=None, **kw)
                 m = m.to(device)
             break
@@ -116,6 +124,8 @@ for cls, kw in [(AutoModelForCausalLM, {{'trust_remote_code': True}}), (AutoMode
     if m is not None:
         break
 
+sys.stdout = _original_stdout
+
 if m is None:
     print(json.dumps({{'error': 'Unable to load model', 'details': load_errors}}))
     exit(1)

+ 11 - 11
result.txt

@@ -1,12 +1,6 @@
-finetune-backend  | INFO:     Started server process [1]
-finetune-backend  | INFO:     Waiting for application startup.
-finetune-backend  | 2026-05-20 02:12:02 | INFO     | peft-platform | JobQueue started with 2 workers
-finetune-backend  | INFO:     Application startup complete.
-finetune-backend  | INFO:     Uvicorn running on http://0.0.0.0:8010 (Press CTRL+C to quit)
-finetune-backend  | INFO:     127.0.0.1:53198 - "GET /health HTTP/1.1" 200 OK
-finetune-backend  | INFO:     172.20.0.4:35898 - "GET /api/v1/models/ HTTP/1.0" 200 OK
-finetune-backend  | 2026-05-20 02:13:47 | INFO     | peft-platform | Remote test result: code=0, stdout_len=1514, stderr_len=4075
-finetune-backend  | 2026-05-20 02:13:47 | INFO     | peft-platform | stdout (first 500): 1,7,16,128,128,64,1,1,None
+finetune-backend  | INFO:     172.20.0.4:38278 - "GET /api/v1/models/ HTTP/1.0" 200 OK
+finetune-backend  | 2026-05-20 02:43:37 | INFO     | peft-platform | Remote test result: code=0, stdout_len=1793, stderr_len=2305
+finetune-backend  | 2026-05-20 02:43:37 | INFO     | peft-platform | stdout (first 500): 1,7,16,128,128,64,1,1,None
 finetune-backend  | 1,7,16,128,128,64,1,1,None
 finetune-backend  | 1,7,16,128,128,64,1,1,None
 finetune-backend  | 1,7,16,128,128,64,1,1,None
@@ -25,7 +19,13 @@ finetune-backend  | 1,7,16,128,128,64,1,1,None
 finetune-backend  | 1,7,16,128,128,64,1,1,None
 finetune-backend  | 1,7,16,128,128,64,1,1,None
 finetune-backend  | {"generated_te
-finetune-backend  | 2026-05-20 02:13:47 | INFO     | peft-platform | stderr (first 500): Current Triton version 3.0.0 is below the recommended 3.2.0 version. Errors may occur and these issues will not be fixed. Please consider upgrading Triton.
+finetune-backend  | 2026-05-20 02:43:37 | INFO     | peft-platform | stderr (first 500): Current Triton version 3.0.0 is below the recommended 3.2.0 version. Errors may occur and these issues will not be fixed. Please consider upgrading Triton.
 finetune-backend  | Current Python version 3.10 is below the recommended 3.11 version. It is recommended to upgrade to Python 3.11 or higher for the best experience.
 finetune-backend  | torch.compile is not available in Python 3.10, using identity decorator instead
-finetune-backend  | /opt/conda/lib/python3.10/site-packages/torchvision/datapoints/__init__.py:12: UserWarning: The torchvision.datapoints
+finetune-backend  | 
+finetune-backend  | Loading weights:   0%|          | 0/320 [00:00<?, ?it/s]
+finetune-backend  | Loading weights:   0%|          | 1/320 [00:01<10:04,  1.89s
+finetune-backend  | INFO:     172.20.0.4:38294 - "POST /api/v1/models/test HTTP/1.0" 200 OK
+finetune-backend  | INFO:     127.0.0.1:46336 - "GET /health HTTP/1.1" 200 OK
+finetune-backend  | INFO:     127.0.0.1:45404 - "GET /health HTTP/1.1" 200 OK
+finetune-backend  | INFO:     127.0.0.1:42132 - "GET /health HTTP/1.1" 200 OK