mosaicml / llm-foundry

LLM training code for Databricks foundation models
https://www.databricks.com/blog/introducing-dbrx-new-state-art-open-llm
Apache License 2.0
3.98k stars 523 forks source link

Providing an input context. #200

Closed thusithaC closed 1 year ago

thusithaC commented 1 year ago

Hi,

What is the appropriate format for providing an input context to the prompt? I tried below but, seems the model fails at seemingly easy questions similar models can answer, and I'm giving it the benefit of the doubt that it is a prompt issue or something with my config? .

model_name = 'mosaicml/mpt-7b-instruct'

INSTRUCTION_KEY = "### Instruction:" RESPONSE_KEY = "### Response:" END_KEY = "### End" INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request based on the Input if any input is provided." INPUT_CONTEXT = """### Input: {context}""" PROMPT_FOR_GENERATION_FORMAT = """{intro} {input_context} {instruction_key} {instruction} {response_key} """.format( intro=INTRO_BLURB, input_context=INPUT_CONTEXT, instruction_key=INSTRUCTION_KEY, instruction="{instruction}", response_key=RESPONSE_KEY, )

config and result:

`def get_input_data(inputs, context=""): data = { "inputs": inputs, "context": context, "temperature": 1, "top_p": 0.92, "top_k": 0, "max_length": 1024, "use_cache": True, "do_sample": False, "repetition_penalty" : 1.1 } return data

prompt = "what is Driver protection cover?" context = "Driver Protection Cover is extra cover We automatically provide with Your NRMA Compulsory Third Party (CTP) Insurance on most passenger Vehicles and some goods Vehicles. See Table 1. for the Vehicles that We cover and those We do not cover.Driver Protection Cover provides the driver of a covered Vehicle who suffers one or more of the injuries listed in the specified injuries table with a set payment if the driver was at-fault in the accident in which they were injured"

response = predict_fn(get_input_data(inputs=prompt, context=context), model_and_tokenizer) response`

'NRMA CTP insurance covers you against claims made by other people when you\'re responsible for causing injury to them, but it doesn\'t protect your own vehicle from damage caused by another person\'s negligenceThe Best Way To Get A Car Loan With Bad Credit - Auto Loans For People With Poor Or No Credit History | Edmunds\nEdmunds has information about car loans including how much money can be borrowed, what interest rates are available, whether there will be fees charged...\nhttps://www.edmunds.com/car-finance/how-to-get-a-loan-with-bad-credit#overview_of_your_options\nIf you have bad credit, getting approved for auto financing may seem impossible — especially since many lenders require good credit scores as part of their lending criteria.. But don’t give up hope! There are still ways to get financed through dealerships and third party finance companies even though you might have poor credit history. Here we\'ll explain all your options so you know exactly where to start looking for help finding affordable transportation while building better financial habits over time.\nWhat Is The Average Interest Rate On An Auto Loan In 2023?\nInterest rate refers to the cost associated with borrowing funds; this includes both principal payments due each month along with additional charges such as origination costs, late penalties, prepayment penalties etc., depending upon the type of loan product selected during application process. Generally speaking average APR ranges between 5% – 12%, however these numbers vary significantly across different types of vehicles purchased via various sources like banks vs credit unions versus online direct lender services offered directly by automobile manufacturers themselves without requiring middleman involvement within transactional processes involved throughout entire buying experience cycle leading right down until finalizing purchase contract signing stage itself...\nHow Much Does It Cost To Buy A New Car And Finance It Through My Bank?\nWhen purchasing new cars today consumers often choose to use bank financing rather than paying cash because it allows them to spread out monthly expenses into smaller amounts making budgeting easier overall compared to larger lump sum payments required otherwise under traditional "cash only" scenarios. However before deciding which method works best for individual needs its important understand total cost incurred during entire ownership period starting from initial acquisition price paid plus ongoing monthly repayments amount calculated according to specific terms agreed upon between buyer(s) & seller(s). Total estimated annualized cost varies widely dependent primarily upon several key factors outlined below :\n1.) Down Payment Amount Paid Upfront During Purchase Process -- Higher initial deposit size reduces amount owed after completion date thus reducing long term debt burden carried forward year after year thereafter 2.) Length Of Repayment Term Chosen By Consumer -- Longer duration results higher cumulative expense owing over lifetime 3.) Annual Percentage Rates Charged As Part Of Financing Agreement -- Lower effective yearly percentage charge results lower net cost accrued 4.) Additional Fees / Penalties Assessed Throughout Entire Ownership Period Depending Upon Specific Terms Agreed Upon Between Seller & Purchaser -- Examples include early termination penalty clauses assessed should consumer decide sell off vehicle prior expected contractual maturity dates imposed by financier company itself regardless whether intentional act committed intentionally done deliberately purposely intended purposefully planned ahead knowing full well consequences likely outcome result consequence unintended unforeseen unexpected unfortunate unintentional accidental unknown casualty collateral consequential damages resulting loss arising harm happening misfortune mishap mischance inconvenience distress detriment disadvantage deprivation hurt pain suffering discomfort trouble difficulty hardship adversity calamity disaster tragedy ruinousness ruination destruction wreckage devastation catastrophe woe misery plight predicament agony grief sorrow affliction soreness torture anguish pangs torment aches pains throes spasms cramps twinges stabs pricks prickles smarts burns blisters scalds bites scratches bruises chafings rashes boils sunburns heat rash hives bug bite poison ivy insect sting mosquito bite bee sting jellyfish sting spider bite scorpion sting snake bite tick bite mite bite lice infestation fleas ticks bed bugs roaches ants silverfish centipedes millipedes sowbugs maggots gnats fruit flies mosquitoes houseflies hornets firebrats earwigs clothes moths clothing mites cockroaches crickets meal worms pill bugs woodlice slugs snails millipedes mantis shrimp centipede crab spiders earthworm eels c'

samhavens commented 1 year ago

That is a very high temperature, you might want to bring it down to closer to 0.1 or so. repetition penalty is also very high

You can see the defaults in the demo here https://huggingface.co/spaces/mosaicml/mpt-7b-instruct/blob/main/app.py#L157

thusithaC commented 1 year ago

Thanks, Temperature was the main issue.