Use the BetterTransformer pipeline for faster inference

#5
by lgrobol - opened
Files changed (2) hide show
  1. app.py +2 -2
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- pipeline = pipeline(task="translation", model="lgrobol/m2m100_418M_br_fr")
5
 
6
  def predict(texts):
7
  predictions = pipeline(texts.splitlines(), src_lang="br", tgt_lang="fr")
 
1
  import gradio as gr
2
+ from optimum.pipelines import pipeline
3
 
4
+ pipeline = pipeline(task="translation", model="lgrobol/m2m100_418M_br_fr", accelerator="bettertransformer")
5
 
6
  def predict(texts):
7
  predictions = pipeline(texts.splitlines(), src_lang="br", tgt_lang="fr")
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  sentencepiece
2
  transformers
3
  torch
 
1
+ optimum
2
  sentencepiece
3
  transformers
4
  torch