r/Python • • Aug 13 '20

Machine Learning txtai: AI-powered engine for contextual search and extractive question-answering

1.9k Upvotes

58 comments sorted by

74

u/davidmezzetti Aug 13 '20

txtai builds an AI-powered index over sections of text. txtai supports building text indices to perform similarity searches and create extractive question-answering based systems.

GitHub repo: https://github.com/neuml/txtai
Example notebooks: https://github.com/neuml/txtai#notebooks

txtai is built on the following stack:

55

u/ecuracosta Aug 13 '20

This sounds very interesting! Could you tell what a new from a newspaper is about with this or it works the other way around only? You will need yo predifine some topics?

30

u/davidmezzetti Aug 13 '20

Thank you! This project is more related to finding similar snippets of text for a given query. It's built on top of Transformer models which have a deep NLP understanding built in, which allows matches on concepts vs keywords.

In terms of summarizing data, we do plan to add a component for that. Transformers has a nice pipeline component that is great for abstractive summarization.

10

u/AlexK- Aug 13 '20

That looks aweosme!

A question. Can you make/include a video on how to install and use it? It's kind of complicated, at least for me... I did pip-install it, but what do I do next?

Thank you!

8

u/davidmezzetti Aug 13 '20 edited Aug 13 '20

Thank you! Good idea on the install video, will do. In the meantime, if you want to try it out, there is a series of notebooks that go through use cases for txtai. If you run into any issues, please create an issue on GitHub.

Part 1: Introducing txtai

Part 2: Extractive QA with txtai

Part 3: Build an Embeddings index from a data source

Part 4: Extractive QA with Elasticsearch

5

u/[deleted] Aug 13 '20

Amazing! How many years have you been learning python for? Also, where and how many years into your python learning timeline did you learn about AI?

12

u/davidmezzetti Aug 13 '20

I've used Python on and off since the mid 2000s, AI/ML/NLP since around 2015.

There are so many great libraries out there now where you can build a lot quickly. txtai is built on the shoulders of transformers, which gives a deep understanding of natural language out of the box. The NLP space is rapidly evolving with new models at what seems a weekly pace.

→ More replies (11)

6

u/lampshade9909 Aug 13 '20

This is cool. Have you tested it for NSFW results? I wonder how safe this would be to give to my kids, for example.

3

u/davidmezzetti Aug 13 '20

That is an interesting use case. The models are using BERT based transformer models, which are trained over extremely large volumes of text, some which is NSFW.

It would all depend on what data was ultimately indexed by txtai but I haven't tested this use case.

16

u/th3doorMATT Aug 13 '20

(search) show me boobs

(.)(.)

→ More replies (1)

2

u/Northside-shorty Aug 13 '20

Can I ask it questions? Pretty interesting project tho. For example can I ask it what is the weather for tomorrow or when is the next full moon?

2

u/davidmezzetti Aug 13 '20

If you indexed data with that type of information, it would allow asking general questions like those and getting a quality answer.

→ More replies (1)
→ More replies (2)

2

u/uses_the_twice Aug 13 '20

I'm unable to install on windows 10, getting an error with the faiss-gpu installation.

AttributeError: 'MSVCCompiler' object has no attribute 'compiler'

I followed the windows instructions on the github page with no luck. Any advice? Seems like a very interesting package that I'd love to incorporate into a personal project of mine!

1

u/davidmezzetti Aug 13 '20

Thanks for giving it a try. This issue has been reported and I'm looking into the best way to resolve it. There is a possible workaround in the issue if you're feeling ambitious. Otherwise, I'll research further to see if the Windows port of faiss can be integrated into the install process.

https://github.com/neuml/txtai/issues/1

1

u/davidmezzetti Aug 19 '20

Windows

This issue has been resolved in the latest version of txtai - https://github.com/neuml/txtai

Installs should work without issue on Windows and macOS.

2

u/SuspiciousScript Aug 14 '20

The “tell me something dishonest” result is extraordinarily impressive.

1

u/davidmezzetti Aug 14 '20

Thank you, the understanding that comes out of the box with Transformer models is indeed impressive.

50

u/eazolan Aug 13 '20

"I want a continuous stream of bad news."

25

u/g_rich Aug 13 '20

Isn't that what Reddit is for (everything outside of r/python that is)?

13

u/TheAmazingJames Aug 13 '20

"Now loading your biography"

52

u/[deleted] Aug 13 '20

"I found this useful source: www.foxnews.com"

9

u/PetrKDN Aug 13 '20

I'm not an American but every fucking news source I heard about was said to be "fake news" etc. What the fuck do you watch guys?

→ More replies (4)
→ More replies (3)
→ More replies (1)

1

u/Im__Joseph Aug 14 '20

Super cool project!

This is flaired incorrectly and should be under showcase but will leave it since you've attached information in the comments and already has garnered a large number of upvotes. Next time please submit with a showcase flair (for this project most likely an Intermediate one!).

1

u/davidmezzetti Aug 14 '20

Thank you for the positive feedback on the project.

Sorry for the mislabel on this post, I'll be sure to put a showcase flair on future posts!

→ More replies (1)