Giter VIP home page Giter VIP logo

french-sentiment-analysis-with-bert's Introduction

Hi there !

My name is Théophile Blard and I'm a Machine Learning Engineer. I'm french, currently living in Rennes.

Linkedin Badge Gmail Badge

🔧 Technologies & Tools

Github Stats Top Langs

french-sentiment-analysis-with-bert's People

Contributors

dependabot[bot] avatar theophileblard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

french-sentiment-analysis-with-bert's Issues

Length of text passed to nlp pipeline

I have quite long texts that I want to label using your module. I run into the same problem over and over again using the nlp pipeline. Here is my code :

from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
from transformers import pipeline
from tqdm import tqdm

tokenizer = AutoTokenizer.from_pretrained("tblard/tf-allocine", use_fast=True)
model = TFAutoModelForSequenceClassification.from_pretrained("tblard/tf-allocine")

nlp = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer)

text = """
    DECU!!! Je suis venu a axa pour un devis le coeur bien décider de quitter la macif. J'ai apprécié la rapidité du rappel pour discuter des propositions de axa. Mais hélas, c'est le cauchemar ensuite. L'insistance de vouloir conclure une vente sans ECOUTER les besoins du client me met hors de moi. A plusieurs reprises, on lui explique que je souhaitais comparer ce qui était comparable, donc je lui demande des devis pour une couverture TOUS RISQUES, ainsi que le depannage 0KM et le pret d'un vehicule de location en cas de reparation, elle me dit oui oui oui, voici mon offre a 30e moins cher MENSUEL!
    Quelle bonne affaire! je suis ravi avec la MACIF!
     "- Il faut absolument se depecher, l'offre est que pour aujourd'hui!! 
      - j'ai besoin de reflechir madame, j'en discute avec mon conjoint.
      - Okay, offre jusqu'a demain. "
    le lendemain, l'excitation l'emporte, si j"economise 300e a l'année pour la meme couverture, le debat n'est pas long. Je reconfirme les couvertures, et elle dit oui, donc j'accepte.
    Je recois mon contrat d'assurance, et je me rend compte que c'est au tiers que la vendeuse m'a souscrit. Je rappelle pour avoir des explications, on me dit que non, elle avait bien expliqué. Je dis non, merci. Je veux etre couvert TOUS RISQUES. Elle me dit que je peux baisser mes garanties, et pas les augmenter. Je suis perdu... Je n'ai jamais entendu parler d'assureur qui refusait d'augmenter de couverture de garanties au souhait du client.
    Je me renseigne autour de moi, et je trouve l'article 112-9 du code des assureurs, qui protege les clients avec un droit de retractation de 14 jours ouvrés suite un achat/vente par telephone ou en ligne. Le service gestion de cette meme plateforme telephonique m'INFORME que cette loi n'est pas d'actualité, que meme si AXA.fr l'affiche sur son site web, ils n'en tiennent pas compte!! 
    La blague c'est que une conseillere d'une agence situé sud Loire a Rezé (BIEN EN FRANCE, contrairement a cette plateforme telephonique) m'INFORME bel et bien que j'ai droit a ce recours de retractation en cas d'insastifaction dans les 14 jours ouvré et que cette situation n'aurait jamais eu lieu si j'aurais été face a face un conseiller qui aurait fait son travail comme il le fallait, c'est a dire ECOUTER LE CLIENT ET SES BESOINS! 
    J'envoi mes lettres de retractation selon le conseil de la conseillere (FRANCAISE!) parce que je refuse d'écouter mesdames ASMA, JASMINE, FAAD, NMASRI et vendeuse SARA et n'importe qui d'autre de ce centre d'appels à l'adresse suivante: centre de service internet - TSA 81110 69836 Saint Priest CEDEX) Ces gens la ne cherche pas a me proposer une couverture tous risques, ni a une retractation legale. J'envoi la meme lettre au siege de AXA a paris (25 ave matignon 75008 Paris) et j'irai jusqu'au bout de ce litige.. PAS D'HONNEUR ET DE RESPECT pour des affaires de ce genre. Je suis quelqu'un avec des principes, aujourd'hui les gens de AXA ne les respectent pas.
    Nous nous engageons a faire ce qu'on dit, on a que notre honneur dans ce monde... des gens qui vous disent on vous rappelle et ne le font pas, ce ne sont que des laches, sans professionalisme et ne meritent pas de representer le groupe AXA.
""""

nlp(text)

I get the following error :

InvalidArgumentError: indices[0,512] = 514 is not in [0, 514) [Op:ResourceGather]

See attachment for more details on the error. Can someone help me ? Thank you !

error_nlp_pipeline.txt

applied to tweets

Hi again,

Hope you are all well again !

Wanted to know if this sentiment analysis could be applied to tweets, and how ?

Have a great week-end !

Cheers,
Luc

Tester le modèle de Birt entrainé chez moi

Bonjour Théophile,

J'espère que vous allez bien,

J'ai une question svp, concernant le modèle Birt pour l'analyse de sentiment qui est sur la page github:
https://github.com/TheophileBlard/french-sentiment-analysis-with-bert
J'ai terminé l'entraînement du modèle et j'ai obtenu mon modéle tf_model.h5, que je veux tester son efficacité sur mon pc, par contre je savais pas comment faire, pouvez vous svp m'envoyer le code afin de tester des phrases et des expressions spécifiques à mon étude ?
Je vous en remercie d'avance pour votre aide et votre soutien.

Cordialement.

A propos du data set

Bonjour,
c'est vraiment un beau travail ! Dites, vous pouvez en dire plus sur la constitution du jeu de données ? d'où viennent les annotations ? Aggregations des scores des reviews ? vote des utilisateurs ?

Djamé

First steps ..

Hi I'm trying to use your transformer in one of my program.
Saddly I have this error message :

Traceback (most recent call last):
  File "/home/mguiraud/Documents/text-analysis-pipeline/main.py", line 11, in <module>
    from text_analysis import perform_sentiment_analysis
  File "/home/user/Documents/text-analysis-pipeline/text_analysis.py", line 10, in <module>
    model = CamembertForSequenceClassification.from_pretrained('tblard/tf-allocine', num_labels=2)
  File "/home/user/Documents/text-analysis-pipeline/env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2535, in from_pretrained
    raise EnvironmentError(
OSError: tblard/tf-allocine does not appear to have a file named pytorch_model.bin but there is a file for TensorFlow weights. Use `from_tf=True` to load this model from

WHat should I do ?

Runnable PyTorch Version of the Code

Hi. Is there a PyTorch version of this code repo? If so, how can I use it with the PyTorch library instead of the TensorFlow framework? Thanks in advance.

👍

Bonjour Théophile !
Superbe repo bravo 👏👏
Serais tu dispo pour en discuter ?
A très vite
Nicolas

Prediction scores

With 🤗Transformers pipelines it's very easy to get prediction scores, for each class.

Bonjour,
Ma question se repose sur le code que vous avez utilisé pour calculer le pourcentage ( score) pour chaque sentiment (positive et negative), je le trouve pas sur votre page de github , le résultat d'affichage que je parle est montré sur cette page : https://huggingface.co/tblard/tf-allocine?text=Je+t%27appr%C3%A9cie+beaucoup.+Je+t%27aime.
Pour moi, je veux exécuter ce code sur mon propre script et pas seulement tester le résultat sur le site.
Pouvez vous svp de l'ajouter sur votre page github ou de me l'envoyer directement sur ma boite email: [email protected].
Merci pour votre aide.

Originally posted by @hodhoda in #3 (comment)

1. First instantiate Tokenizer & Model

from transformers import AutoTokenizer, TFAutoModelForSequenceClassification
from transformers import pipeline

tokenizer = AutoTokenizer.from_pretrained("tblard/tf-allocine")
model = TFAutoModelForSequenceClassification.from_pretrained("tblard/tf-allocine")

2. Then create pipeline

Do not forget to set the return_all_scores parameter to True, otherwise the pipeline will only output the probability of the predicted class.

nlp = pipeline('sentiment-analysis', model=model, tokenizer=tokenizer, return_all_scores=True)

3. Last, feed the pipeline

result = nlp("J'aime le camembert")
result
[[{'label': 'NEGATIVE', 'score': 0.21667276322841644},
  {'label': 'POSITIVE', 'score': 0.7833272218704224}]]

TensorFlow JS

Bonjour,

J'ai essayé de convertir votre modèle (qui semble être le seul pertinent pour du sentiment analysis sur des textes français) au format TensorFlowJS (https://www.tensorflow.org/js/tutorials/conversion/import_keras?hl=fr) mais sans succès...

J'ai d'abord essayé de convertir directement le fichier Keras h5 trouvé sur hugging face mais il semble que celui-ci ne contient que les pondérations d'après ce que j'ai compris.

J'ai alors monté le projet en python comme expliqué et cela marche très bien.

J'ai ensuite essayé d'enregistrer le modèle récupéré par ligne suivante dans plusieurs format :

model = TFAutoModelForSequenceClassification.from_pretrained("tblard/tf-allocine")

d'abord directement au format TFJS :
tfjs.converters.save_keras_model(model, './tfjs2')

J'ai alors un message qui me dit que le model de peux pas être enregistré dans ce format et qu'il faut que je l'enregistre au format TF saved model :
Saving the model to HDF5 format requires the model to be a Functional model or a Sequential model. It does not work for subclassed models, because such models are defined via the body of a Python method, which isn't safely serializable. Consider saving to the Tensorflow SavedModel format (by setting save_format="tf") or using save_weights.

puis au format Keras afin de réessayer la conversion :
tensorflow.keras.models.save_model(model, 'test.h5')

Même erreur qu'avec TFJS

et enfin au format TensorFlow saved model :
tensorflow.saved_model.save(model, './tfmodel')

La ça marche bien mais la conversion ne marche pas mieux j'ai cette erreur :
Unsupported Ops in the model before optimization : Einsum

J'ai fini par en conclure que le modèle n'était pas compatible avec une transformation vers TFJS ce qui semble être assez commun d'après la documentation.

Pensez-vous qu'il est possible de faire marcher ce modèle dans TFJS ?

N'hésitez pas a me demander plus de précisions si je ne suis pas clair.

Merci d'avance.

create an api / online demo

Hi,

Hope you are all well !

Yeah, for sure, an online service demo would be awesome.
When do you think you can make it live ?

Cheers,
Luc Michalski

Getting word embeddings after training the model

Hi Théophile,

I hope you are doing well.

I would like to obtain word embeddings after having trained the model. That is, first, I will use training data with sentiment labels to generate the model. Then I would feed a test sentence (e.g. Tu as aimé cela.) into the system. Afterwards, I would like to get the vectors of the words Tu, as, aimé and cela, created with respect to this model. That is, in the testing phase, I am interested in those word embeddings only, not the predicted sentiment label of the test data. Is it possible? If so, how could I perform this task? Could you please show it to me through an example code snippet?

Thank you very much for your interest in advance,
Cem Rifki Aydin

Original Scraping files

Hi
I will be interested by your allocine scraping files (reviews ratings between 0 to 5) . Could you share me .pickle files that compile all the extracted data. It will be very helpful.
Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.