Update brain.py
Browse files40 unmodified lines4142434445464748495051525338 unmodified lines929394959697989910040 unmodified linesdef _load_models(self):try:print("[GPU] Chargement de Qwen 7B sur le T4...")model_path = hf_hub_download(repo_id="bartowski/Qwen2.5-7B-Instruct-GGUF",filename="Qwen2.5-7B-Instruct-Q4_K_M.gguf")self.llm = Llama(model_path=model_path, n_ctx=max(2048, min(32768, int(os.environ.get("LG_QWEN_CONTEXT", "8192")))), n_gpu_layers=-1, verbose=False)print("[GPU] Modèle LLM chargé.")print("[CPU] Chargement du modèle d'embedding...")self.encoder = SentenceTransformer('all-MiniLM-L6-v2')self.vector_db = faiss.IndexFlatL2(384)38 unmodified linesif not self.llm:return "{}"try:response = self.llm(prompt, max_tokens=max_tokens,stop=["<|im_end|>"], temperature=0.3)return response['choices'][0]['text'].strip()except Exception:return "{}"40 unmodified lines4142434445464748495051525354555657585960616238 unmodified lines10110210310410510610710810911011111211311440 unmodified linesdef _load_models(self):try:# CHANGEMENT MAJEUR : Qwen2.5-Coder-14B (version quantifiée Q4_K_M)print("[GPU] Chargement de Qwen2.5-Coder-14B sur le T4...")model_path = hf_hub_download(repo_id="bartowski/Qwen2.5-Coder-14B-Instruct-GGUF",filename="Qwen2.5-Coder-14B-Instruct-Q4_K_M.gguf")self.llm = Llama(model_path=model_path,n_ctx=8192, # Contexte large pour digérer tout le coden_gpu_layers=-1, # 100% sur le GPU T4n_batch=512,verbose=False,)print("[GPU] Modèle LLM 14B chargé avec succès.")print("[CPU] Chargement du modèle d'embedding...")self.encoder = SentenceTransformer('all-MiniLM-L6-v2')self.vector_db = faiss.IndexFlatL2(384)38 unmodified linesif not self.llm:return "{}"try:# Température basse pour un code déterministeresponse = self.llm(prompt,max_tokens=max_tokens,stop=["<|im_end|>"],temperature=0.1,)return response['choices'][0]['message']['content'].strip() if 'message' in response['choices'][0] else response['choices'][0]['text'].strip()except Exception:return "{}"
brain.py+22-8