mrseanryan / gpt-dm

Data modelling via natural language using an LLM. Outputs JSON or SQL. Also generates Test data in SQL or CSV format.
MIT License
2 stars 0 forks source link

Try self hosted Mistral 7B-instruct #9

Open mrseanryan opened 7 months ago

mrseanryan commented 7 months ago

Mistral 7B instruct is easy to host and already seems promising, without any fine tuning:

Prompt format:

text = "<s>[INST] What is your favourite condiment? [/INST]"
"Well, I'm quite partial to a good squeeze of fresh lemon juice. It adds just the right amount of zesty flavour to whatever I'm cooking up in the kitchen!</s> "
"[INST] Do you have mayonnaise recipes? [/INST]"

Example:

<s>[INST] 

Follow these steps:

- Step 1: Ask the user what is the name of the application. In later steps, this will be referred to as <application-name>.
- Step 2: Ask the user for the list of entity names. In later steps, this will be referred to as <entities-list>.
- Step 3: Ask the user to describe how the entities are related.
- Step 4: Create a database schema in JSON for the application named <application-name>.
This application manages the entities: <entities-list>.
The entities are related as follows: <entity-relationships-list>.

The output MUST be in JSON only, based on the following example:
---
{
  "application": “my-cars",
  "entity-names": ["Users","Projects","Tasks"],
  "entity-attributes": {
    <entity-A-name>: [<list of suitable attributes>],
    <entity-B-name>: [<list of suitable attributes>]
  },
    "entity-relationships": {
    <entity-A-name>: {
      <entity-B-name>: “<multiplicity>”
    }
  }
}
---

Where:
  - <multiplicity> can be one of these: one-to-one, one-to-many, many-to-one, many-to-many
  - <entity-A-name> is the name of some entity
  - <entity-B-name> is the name of some other entity

IMPORTANT: For step 4, only output valid JSON.
[/INST] Sure, I'd be happy to help you with that! Can you please provide me with more information about the entities and their relationships?</s>

[INST]
A Car has Wheels. A Wheel has a Tyre.
[/INST]
Great, thank you for providing the entity relationship details. Based on your input, here's an example of how the JSON output could look like:
---json
{
    "application": "car_app",
    "entity-names": ["Cars", "Wheels", "Tyres"],
    "entity-attributes": {
        "Cars": ["color", "make", "model", "year"],
        "Wheels": ["size", "brand", "material"],
        "Tyres": ["pressure", "tread", "wear"]
    },
    "entity-relationships": {
        "Cars": {
            "Wheels": "many-to-many"
        },
        "Wheels": {
            "Tyres": "many-to-many"
        }
    }
}
``</s>
[INST]Generate example data in JSON format[/INST]
Sure, here's an example of how the data for each entity could look like in JSON format:
---json
// Cars
{
  "id": 1,
  "color": "red",
  "make": "Toyota",
  "model": "Camry",
  "year": 2021
}

// Wheels
{
  "id": 1,
  "size": 15,
  "brand": "Goodyear",
  "material": "steel"
}

// Tyres
{
  "id": 1,
  "pressure": 30,
  "tread": 8,
  "wear": 20
}
---
Please note that the above data is just an example and may not necessarily reflect real-world data. The actual data would depend on the specific requirements of the

note: in this example, backtick ` x 3 was replaced with---` so that I could paste it into Markdown format