Melissa-AI / Melissa-Core

A lovely virtual assistant for OS X, Windows and Linux systems.
MIT License
491 stars 201 forks source link

ConceptNet 5 And Integration With Melissa #21

Closed tanay1337 closed 4 years ago

tanay1337 commented 8 years ago

Integration of ConceptNet 5 using its web API to make Melissa smarter.

This will require:

  1. Study of ConceptNet 5 and its implementation in Python.
  2. Integration of the generated module with Melissa.
neilnelson commented 8 years ago

Here is the API for ConceptNet 5.

Melissa's business_news_reader.py provides code to obtain a return from an http request. This page shows how to get a return from an http request and to translate the JSON return to a Python multilevel dictionary.

The issues we face now are how do we translate a user expression into a form that when sent to ConceptNet will return JSON data that we can then translate to an action indicated by the user's expression? We have a basic sequencing of the suggested code but where the two translations are not yet well defined.

In Melissa we extract particular words (one or more) from the user's expression and then use those words as keys (pointers, connectors) to an action. Api.ai has the developers enter a list of words and phrases, and sentences that are used by a machine learning program to generalize those list elements in a way that can identify words and their sequences in a user's expression as belonging to the action attached to the developer's list. We can also see where Api.ai's context and domain could affect (limit) the action search used by the generalized word match. And noting that matches will likely be according to some probability score, ranking the possible resulting actions, inherent in a machine learning solution. A machine learning solution requires a training sequence and, in this case, an at run-time classification (identification or recognition) sequence.

The ConceptNet 5 api gives an interesting example of

To find the somewhat unintuitive URI for the term "ground beef", go to: http://conceptnet5.media.mit.edu/data/5.4/uri?language=en&text=ground_beef

which gets us little closer in that, for example, when a user gives the expression

I would like to buy some ground beef.

We might send that to ConceptNet as

http://conceptnet5.media.mit.edu/data/5.4/uri?language=en&text=i_would_like_to_buy_some_ground_beef

ConceptNet provides a return of

{ "uri": "/c/en/i_would_like_to_buy_some_grind_beef" }

This return suggests we could do the following

http://conceptnet5.media.mit.edu/data/5.4/c/en/i_would_like_to_buy_some_grind_beef

ConceptNet provides an empty return of

{ "edges": [], "numFound": 0 }

We might try only the most primary words as

http://conceptnet5.media.mit.edu/data/5.4/uri?language=en&text=buy_ground_beef

The return is

{ "uri": "/c/en/buy_grind_beef" }

Which we then use as

http://conceptnet5.media.mit.edu/data/5.4/c/en/buy_grind_beef

Giving us an empty return

{ "edges": [], "numFound": 0 }

What comes to mind at this point is that we could separate buy and ground beef, send those separately to ConceptNet that will get us two returns we could then combine to translate to an action. How to separate three words into two groups useful is an issue or we could send all three words individually to ConceptNet.

We are then thinking about how we can translate a combined ConceptNet return into an action. But at this point I suggest we a bit stuck. The coding solution distance from the ConceptNet return to the action is much the same as the coding distance from the user's expression to action in that we still need some method of identification in either case that connects to an action.

Api.ai constructs this connection by having the developer enter a list of words and phrases and the connecting action that the machine learning uses to make the connection. At the moment ConceptNet is a way that could give us a route to avoid having a developer provide a list of words and phrases that machine learning could use to generalize toward a classification of the users expression, but that first translation, if it could be done reasonably, would not likely be done in real time. The second translation of connecting a classification to an action will require some generalization of the action description to connect to the the user's expression generalization. This requirement of an action description then emulates Api.ai's method, in a somewhat backward manner, making the forward direction from user expression, through ConceptNet a little superfluous.

Conclusion

What I am seeing at this point is still a method too vague or cumbersome to make near-term headway on. But clearly it is an area that if could be solved would be a commanding advance on methods currently available.

Off hand I think we are looking at a compilation of domains in the manner of Api.ai and where those might be enhanced by some real-time user expression similarity matching through ConceptNet or similar, and noting that coding such a similarity procedure is not yet well defined.

Given that we would be constructing domains and these are collections of actions in heading areas (time, news, info) connected through a machine learning generalization, we would want to do that in an efficient (automated) way that might use ConceptNet. Another aspect is that for these domains (databases) to be used requires that they be downloaded or connected through a server.

neilnelson commented 8 years ago

Superfluous is not quite the right word. We can view the words and phrases entered in to Api.ai to connect a user's expression to an action as the action's description. The actions, in general are well-determined but the expressions are not and that some expressions intended for one action will be instead sent to a different action because of an inability of the Api.ai method to correctly classify expressions at some probability.

The classification accuracy will be determined by the volume and separability of the words and phrases entered and the method applied. I can see where a developer might enter a large number of well designed words and phrases to increase the separability (given the method) that we could then say is a more precise and complex description of the action. My meaning is that we can not avoid an action description of some kind and that Api.ai's method seems to tend toward a minimal kind of description, one that we might easily emulate, and perhaps a sufficient one. If we think that we have a sufficient description method then going back through ConceptNet would not appear to gain us much given the description we already must have and a method similar to Api.ai.

However, on thinking about how Api.ai would use machine learning to generalize its descriptions I am not quickly seeing how that would be better than using commonly known search engine methods. The Coursera class Natural Language Processing by Dan Jurafsky, Christopher Manning from Stanford has some good info along this line.

Noting that we are working to separate user expressions with good accuracy according to user intent, using machine learning after a thorough search engine method and additionally with user refinement (the user or developer says that the returned action was their intent or not) would increase user expression separation.

Search engine methods and machine learning will go toward an Api.ai domain kind of method. I can see where ConceptNet will be a help in providing a scale of material useful for creating a search engine database.

neilnelson commented 8 years ago

This NLTK page has a section 2.2 Identifying Dialogue Act Types that takes sentences and classifies them into one of 15 dialogue act types. We could substitute Melissa actions for dialogue act types to have a training method that takes sentences to actions. But this also illustrates an issue with machine learning where it is best to have a large volume of correctly labeled sentences in order to do training. The examples uses 10,000 labeled posts. Getting user confirmation (that an action was the correct one or not for the expression provided) over many users and time would help a machine learning approach.

The few words and phrases provided by a developer at Api.ai would not seem sufficient unless we can find a way that such a small number of expressions provides enough machine learning accuracy. Whereas a search engine method would be a direct extension of the words to actions method now used in Melissa and where a word similarity and context usage that we could get from ConceptNet might also be applied. For example, ConceptNet should give us synonyms and word context and phrase information useful in a search engine method.

neilnelson commented 8 years ago

I just realized that since Api.ai is processing the millions of user expressions through their server that they have enough data to do machine learning and where they have some way to identify if an action given for a user expression was according to the user's intent. If the provided action does not receive a user response saying it was the wrong action it could be assumed to be the right action.

bhaveshAn commented 6 years ago

I wanna work on this issue.

tanay1337 commented 6 years ago

Please go ahead @bhaveshAn. Do focus on the core aspect and the functionality first and then implementation as the repository is going to undergo a complete overhaul.

tanay1337 commented 6 years ago

@bhaveshAn You can work under @emedvedev's guidance for this.

bhaveshAn commented 6 years ago

@bhaveshAn You can work under @emedvedev's guidance for this.

Sure!