Skip to content
Snippets Groups Projects
Commit 3ab655a1 authored by Ivan Pavlovich's avatar Ivan Pavlovich
Browse files

Ajout d'entaite dans les scripts utilisé

parent 9a54a400
No related branches found
No related tags found
No related merge requests found
# -----------------------------
# Le script ne fait rien. Il met a disposition deux fonction une qui créer un classifier à
# partir du model fine-tuner (./model). Le deuxième classifie une sequence sur des label en utilisant le classifier
# créer dans la première fonction
#
# Ce script ne prend pas de paramètres.
#
# Auteur : Pavlovich Ivan
# -----------------------------
from transformers import pipeline
import os
import sys
......
# https://medium.com/@lidores98/finetuning-huggingface-facebook-bart-model-2c758472e340
# -----------------------------
# Le script affine le modèle BART-Large-MNLI de Facebook AI sur les articles stoquer localement (dataSources/PubMed/save/save_3_years.json)
#
# Ce script ne prend pas de paramètres.
#
# Basée sur : https://medium.com/@lidores98/finetuning-huggingface-facebook-bart-model-2c758472e340
#
# Auteur : Pavlovich Ivan
# -----------------------------
import pandas as pd
import torch
......@@ -18,7 +26,7 @@ from parsers.jsonParser import parseJsonFile
from variables.pubmed import NCDS, NCDS_MESH_TERM
DATASET_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../testModel/dataset"))
TMP_DATA_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../dataSources/PubMed/tmp"))
TMP_DATA_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../dataSources/PubMed/save"))
SAVE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "./save"))
MODEL_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "./model"))
LOGS_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "./logs"))
......
......@@ -13,4 +13,4 @@ module load CUDA/12.3.0 GCC/12.2.0 Python/3.10.8 Qt5/5.15.7
source ../../.venv/bin/activate
python3 facebook-bart-large-mnli.py
\ No newline at end of file
python3 finetunning-multi-label.py
\ No newline at end of file
# -----------------------------
# Le script ne fait rien. Il met a disposition deux fonction une qui créer une pipline zero-shot classification à
# partir d un model hugging face. Le deuxième classifie une sequence sur des label en utilisant le classifier
# créer dans la première fonction
#
# Ce script ne prend pas de paramètres.
#
# Auteur : Pavlovich Ivan
# -----------------------------
from transformers import pipeline
import torch
import time
LABELS = [
"Diabetes",
"Cancer",
"Chronic respiratory disease",
"Cardiovascular diseases",
"Mental Health",
"Diabetes type 1",
"Diabetes type 2"
]
# LABELS = [
# "Neoplasms",
# "Diabetes Mellitus",
# "Male",
# "Blood Cells",
# "Arthritis, Infectious"
# ]
MODELS = [
"facebook/bart-large-mnli", # https://huggingface.co/facebook/bart-large-mnli
"MoritzLaurer/bge-m3-zeroshot-v2.0", # https://huggingface.co/MoritzLaurer/bge-m3-zeroshot-v2.0
"MoritzLaurer/DeBERTa-v3-base-mnli-fever-anli",
"MoritzLaurer/deberta-v3-base-zeroshot-v1.1-all-33",
"MoritzLaurer/multilingual-MiniLMv2-L6-mnli-xnli",
"microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract" # https://huggingface.co/microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract
]
def create_classifier(model = MODELS[0]):
def create_classifier(model):
print(f" CUDA available: {torch.cuda.is_available()}")
print(f"CUDA version: {torch.version.cuda}")
print(f"GPUs number: {torch.cuda.device_count()}")
......
# -----------------------------
# Le script ne fait rien. Il met a disposition deux fonction une qui créer un client cohere à
# partir d une clé. Le deuxième classifie une sequence sur des label en utilisant le client
# créer dans la première fonction
#
# Ce script ne prend pas de paramètres.
#
# Auteur : Pavlovich Ivan
# -----------------------------
import cohere
import json
import time
......
# -----------------------------
# Le script ne fait rien. Il met a disposition deux fonction une qui créer un chat gemini.
# La deuxième classifie une sequence sur des label en utilisant le chat créer dans la première fonction
#
# Ce script ne prend pas de paramètres.
#
# Auteur : Pavlovich Ivan
# -----------------------------
import os
import google.generativeai as genai
import json
......
# -----------------------------
# Le script ne fait rien. Il met a disposition une fonction qui classifie une sequence sur des label en utilisant un model ollama
#
# Ce script ne prend pas de paramètres.
#
# Auteur : Pavlovich Ivan
# -----------------------------
from ollama import chat
from ollama import ChatResponse
import json
import time
NCDS = [
"Non-Communicable Diseases",
"Diabetes",
"Cancer",
"Chronic respiratory disease",
"Cardiovascular diseases",
"Mental Health",
"Diabetes type 1",
"Diabetes type 2"
]
def classify(model, sequence, labels):
prompt = 'I need you to give me the labels that could be given to the text (keep in mind that u can put multiple labels and select only the labels that i give you):\n'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment