jonathanjordan21's picture
Update README.md
54a0dfe verified
metadata
language:
  - en
  - id
  - ms
license: apache-2.0
library_name: transformers
datasets:
  - neural-bridge/rag-dataset-12000
  - neural-bridge/rag-hallucination-dataset-1000
pipeline_tag: text2text-generation

Model Details

Model Description

This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.

  • Developed by: Jonathan Jordan
  • Funded by: Lintas Media Danawa
  • Model type: MT5
  • Language(s) (NLP): English
  • Finetuned from model : gooogle/mt5-base

Uses

The model generates answer to the question based on the given context. The model could tell if the question is unanswerable within the context.

Note

There is an issue regarding the consistency of the output. Set temperature to 0 or very close to 0 to achieve more consistent output. Feel free to try to increase the top_k parameter to improve the output further

Prompt Template

<|context|>
James Clerk Maxwell FRSE FRS (13 June 1831 – 5 November 1879) was a Scottish physicist with broad interests who was responsible for the classical theory of electromagnetic radiation, which was the first theory to describe electricity, magnetism and light as different manifestations of the same phenomenon. Maxwell's equations for electromagnetism have been called the "second great unification in physics" where the first one had been realised by Isaac Newton.
With the publication of "A Dynamical Theory of the Electromagnetic Field" in 1865, Maxwell demonstrated that electric and magnetic fields travel through space as waves moving at the speed of light. He proposed that light is an undulation in the same medium that is the cause of electric and magnetic phenomena.[4] The unification of light and electrical phenomena led to his prediction of the existence of radio waves. Maxwell is also regarded as a founder of the modern field of electrical engineering. 
<|user|>
Who is James Clerk Maxwell?
<|assistant|>

Direct Use

!pip install -U transformers
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
model = AutoModelForSeq2SeqLM.from_pretrained("jonathanjordan21/mt5-base-finetuned-RAG")
tokenizer = AutoTokenizer.from_pretrained("jonathanjordan21/mt5-base-finetuned-RAG")

prompt_template = lambda c,q,a : f"<|context|>\n{c}\n<|user|>\n{q}\n<|assistant|>\n{a}"

ctx = """James Clerk Maxwell FRSE FRS (13 June 1831 – 5 November 1879) was a Scottish physicist with broad interests who was responsible for the classical theory of electromagnetic radiation, which was the first theory to describe electricity, magnetism and light as different manifestations of the same phenomenon. Maxwell's equations for electromagnetism have been called the "second great unification in physics" where the first one had been realised by Isaac Newton.
With the publication of "A Dynamical Theory of the Electromagnetic Field" in 1865, Maxwell demonstrated that electric and magnetic fields travel through space as waves moving at the speed of light. He proposed that light is an undulation in the same medium that is the cause of electric and magnetic phenomena.[4] The unification of light and electrical phenomena led to his prediction of the existence of radio waves. Maxwell is also regarded as a founder of the modern field of electrical engineering. 
"""

text = prompt_template(ctx, "who is james clerk maxwell?", "")

tokenizer.batch_decode(model.generate(**tokenizer([text], return_tensors='pt', add_special_tokens=False).to('cuda'), temperature=0, max_new_tokens=256, top_k=1000))