import gradio as gr from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification import torch model_name = "MrAlexGov/is-it-job-ru-q1a8e-lkjvk" # Загрузка tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) classifier = pipeline( "text-classification", model=model, tokenizer=tokenizer, device=0 if torch.cuda.is_available() else -1, truncation=True, max_length=512 ) def predict(text): if not text.strip(): return "❌ **Введи вакансию!**" result = classifier(text)[0] label = result['label'] score = result['score'] if '1' in label: verdict = "✅ Да это вакансия из IT" else: verdict = "❌ НЕ ПОДХОДИТ 😔" return f""" # {verdict} Класс: `{label}` Вероятность: `{score:.1%}` Модель: BERT fine-tune (8900 вакансий) Текст: Обрезан до 512 слов (если длинный) --- Тест: "Junior PHP dev" → подходит 95% """ # Gradio UI iface = gr.Interface( fn=predict, inputs=gr.Textbox( label="📝 Вставь текст вакансии", placeholder="Например Junior PHP developer MySQL Linux Python n8n ИИ VS Code удалёнка 100к", lines=8 # Ввод большой ), outputs=gr.Textbox( # ✅ ФИКС: Textbox с 20 строками (НЕ Markdown) lines=8, label="Результат анализа моделью", container=True ), title="🚀 Мой BERT-фильтр вакансий (дообучение fine-tune на 1000 примерах) + MCP", description="LABEL_1 = подходит (твои скиллы), LABEL_0 = нет. Точность ~90%!", ) iface.launch(mcp_server=True) if __name__ == "__main__": iface.launch()