OpenAI/Codex: Can I create a fine-tuned model for Codex? - json

I'd like to translate user requests into tickets in some sort of structured data format, e.g. JSON. For example:
User: I want to order two chairs and a desk with three drawers on the left side.
Output:
{
"type": "furniture",
"items": [
{ "type": "desk", "qty": 1, "included_items": [{ "type": "drawer", "qty": 3, "position": "left" }] },
{ "type": "chair", "qty": 2 }
]
}
It looks like GPT3 itself is not very-well suited for this task, because output is not in the form of natural language, however Codex might be? But I can't find in OpenAI docs how I can (if it's possible at all?) to create a custome/fine-tuned model for Codex?

#xara Codex does not support a way to fine tune their model.
What you can do is prompt engineering.
Provide the model some demonstrations and try out whether Codex can perovide you with expected output.

It is currently in beta, but you can fine-tune the OpenAI codex model on your custom dataset for a charge to improve its performance. Please refer to the following link for details instruction: https://beta.openai.com/docs/guides/fine-tuning

Related

How to push this JSON to firestore and query the data?

i would like to ask how do we push the JSON below into firestore in Angular?
var customer =
{
"name": "john",
"address": "xxxxx",
"order": {
"bookList": [{
"quantity": "3",
"price": "$2"
},
{
"quantity": "4",
"price": "$1"
}]
}
}
At the same time, i would like to with each address, get the list of all orders from all customers. Was thinking of doing like the json below, i will get the document ID for the orders using the client's document id then i will add to the orders array.
var data2 = {
"address": "xxxxx",
"orders": [{
"id": "1dsd"
},
{
"id": "312312"
}]
}
Im quite unsure on how to achieve these, appreciate any help and advice! It would be great if step by step instructions and explanations are provided!
Thank you!
This article provides a great example of how to import JSON data into Firestore. The user provides a quick tutorial on how to migrate your initial database to Firestore.
I would also like to encourage you to look through this tutorial of using Cloud Firestore in Angular with Angularfire as they will be best suited for what you may be looking for.
Additionally, I would like to point you towards the Angularfire community on Github, as they may provide some insight on your particular implementation. This segment of their documentation discusses ways of querying strategies that you may find useful .

How to store different kind of datas in single bucket in couchbase

I want to store the diff kind of data in same bucket in Couchbase, am googled its suggest doc_type and type parameter , but i don't know how i implement that one in my data,I tried below code but i don't know how to do that?
i didn't seen any example,any help will be appreciate,
JsonObject doc = JsonObject.fromJson(consumerRecord.value().toString());
String id=consumerRecord.key().toString();
bucket.upsert(JsonDocument.create(id, doc));
Couchbase buckets store documents of any kind. You don't have to do anything special. As long as it's valid JSON, it can be stored in a Couchbase bucket.
Now, what you might want is some way to differentiate between different types of documents (for querying purposes, for instance). So, you can put a "type" field (or docType or whatever you'd like) as a kind of 'marker' value. You can see examples of this in the built-in travel-sample bucket. For instance, look at the airline_10 and the route_10000 documents:
airline_10
{
"callsign": "MILE-AIR",
"country": "United States",
"iata": "Q5",
"icao": "MLA",
"id": 10,
"name": "40-Mile Air",
"type": "airline"
}
route_10000
{
"airline": "AF",
"airlineid": "airline_137",
"destinationairport": "MRS",
"distance": 2881.617376098415,
"equipment": "320",
"id": 10000,
"schedule": [ ... ],
"sourceairport": "TLV",
"stops": 0,
"type": "route"
}
Notice that one has a type of "airline", the other has a type of "route". An example of a query to find routes:
SELECT t.*
FROM `travel-sample` t
WHERE t.type = 'route'
LIMIT 10
This is one way to differentiate documents. Also notice that the keys are constructed semantically, so they could also be used. Neither of these are a requirement, so it really depends on how you plan to access documents.

How to build One-To-Many relationships within JSON API

I`m very new to JS/APIs/JSON.
I`ve got an API I built using deployd, a great tool that allows to to quickly set up an API.
My API called "app" has two resources zips and people. Each entry/object in zips has only one property zipcode. Each people has the properties name and phonenumber.
I want to figure out a way to have people be associated with various zipcodes. Either one or many if necessary. This would, as I understand, involve adding a property to people such as assoczipcodes and using a relationship model to indicate with zipcodes are related.
I've done some research here about how a relationship is structured but I simply don't understand the syntax and format.
Q: What datatype is correct for associzipcodes?
Q: What do I enter into each assoczipcodes to indicate which zips are related?
Cristik's answer appears to be outdated. According to the current documentation, you'd want to nest the relationship like this:
{
"type": "people",
"id": "1",
"attributes": {
"name": "John Doe"
},
"relationships": {
"zipcodes": {
"links": {
"self": "http://myserver.com/people/1/zipcodes"
}
}
}
}
Based on the contents from the Resource Relationships section, the simplest approach would be to return an URL for the relationship, and have that URL return all information needed:
{
"type": "people",
"id": "1",
"name": "John Doe",
"links": {
"zipcodes": "http://myserver.com/people/1/zipcodes"
}
}

Representing child objects in JSON for a mobile API

I am designing a JSON API for a mobile app and have to decide how to show child objects from the server to the client. Typically the request from the client to the server will be a single request to sync and the response will include all the objects that need updating. What is the best way to show the objects?
Option A - Nested Children:
{ "articles": [
{ "id" : 1,
"title": "This is the first article",
"comments": [
{"id": "1",
"article_id" : "1",
"title": "A comment on the first article"
}]
},
{ "id" : 2,
"title": "This is the second article",
"comments": [
{"id": "2",
"article_id" : "2",
"title": "A comment on the second article"
}]
}, ]}
OPTION B - All Objects on Their Own
{ "articles": [
{ "id" : 1,
"title": "This is the first article",
}
{ "id" : 2,
"title": "This is the second article",
}]
"comments": [
{"id": "1",
"article_id" : "1",
"title": "A comment on the first article"
},
{"id": "2",
"article_id" : "2",
"title": "A comment on the second article"
}]}
On the client side I can handle either format and build the relationship based on the article_id field so I am not too sure why nest the children, other than that it makes it look nice. However, when I think about writing tests for the client-side, especially the mapping of json to objects it seems easier to show and map each object on its own. I am a beginner here so any thoughts would be helpful.
PS. I am building the server using Rails/Grape and the clients with RestKit/Coredata (iOS) and probably RoboSpice/ORMLite (Android).
That's very subjective. There isn't one correct answer for that. It really depends on whatever approach is more suited to your task and data. You say this is a request used to sync data. How is the data represented and stored on the client side? If flat, like a relational database, then the flat output is probably easier to use. On the other hand, if the client will use the relationships a lot, it's probably better to use the nested structure.
From an API design standpoint, I'd have the endpoint for the articles collection accept a query parameter like expand, with a level number, or named entities, and it would add the nested children accordingly. So, for instance, GET /api/articles?expand=comments would generate output with nested comments, or GET /api/articles?expand=1 to generate output with all immediate children. That way, clients can easily generate the nested output if they need it, or they can query the endpoints for articles and comments separately and concatenate the output if they need the flat data.,

Freebase MQL to list out all commons types for a given word?

I'm trying to figure out how to write a MQL query to get a list of all the types associated to a given word.
For example I tried:
{
"id":null,
"name":null,
"name~=": "SOME_WORD",
"type":"/type/type",
"domain": {
"id": null,
"/freebase/domain_profile/category": {
"id": "/category/commons"
}
}
}​
I found this to list out all the Commons types or categories but haven't yet figured out how to narrow it down for a given input.
[{
"id": null,
"name": null,
"type": "/freebase/domain_profile",
"category": {
"id": "/category/commons"
}
}]​
There are a couple of different ways to do this with different tradeoffs for each.
Use the Search API with a query like this
https://www.googleapis.com/freebase/v1/search?indent=true&filter=%28all%20name{full}:%22uss%20constitution%22%29
You'll get back JSON results which look like this:
{
"status": "200 OK",
"result": [
{
"mid": "/m/07y14",
"name": "USS Constitution",
"notable": {
"name": "Ship",
"id": "/boats/ship"
},
"lang": "en",
"score": 1401.410400
},
...
You can make the matching more liberal by switching the "{full}" to "{phrase}" which will give you a substring match instead of an exact match.
Caveats:
- You'll only get a single "notable type" and it's fixed by Freebase's (unknown) algorithm
- I don't think there's a way to get both USS Constitution & U.S.S. Constitution results
- You can get a list of all types by adding &mql_output={"type":[]}, but then you lose the "notable" type. I don't think there's a way to get both in a single call.
Use MQL
This query returns the basic information that you want:
[{
"name~=":"uss constitution",
"type":[],
"/common/topic/notable_types" : []
}]​
Caveats:
It won't find "uss constitution" which is an alias rather than the primary name (there's a recipe in the MQL cookbook for that though)
It won't find "u.s.s. constitution"
The "notable_types" API is an MQL extension and MQL extensions aren't supported in the new Freebase API, only the legacy deprecated API
You're tied to whatever (unknown) algorithm Freebase used to compute "notability"
Depending on what you are trying to accomplish, you might need something more sophisticated than this (as well as a deeper understanding of what's in Freebase), but this should get you going with the basics.
Did you try:
[{
"name": "David Bowie",
"type": []
}]