Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept Callables as Tokenizers for InMemoryDocumentStore #4720

Open
masci opened this issue Apr 21, 2023 Discussed in #4695 · 3 comments · May be fixed by #7704
Open

Accept Callables as Tokenizers for InMemoryDocumentStore #4720

masci opened this issue Apr 21, 2023 Discussed in #4695 · 3 comments · May be fixed by #7704
Labels
2.x Related to Haystack v2.0 Contributions wanted! Looking for external contributions type:feature New feature or request

Comments

@masci
Copy link
Member

masci commented Apr 21, 2023

Discussed in #4695

Originally posted by farhanhubble April 18, 2023
InMemoryDocumentStore currently only accepts a tokenizing pattern through the argument bm25_tokenization_regex: str = r"(?u)\b\w\w+\b". The underlying BM25 supports a callable though. Removing this restriction will enable correct tokenization of a larger variety of corpora. I ran into this limitation trying to index JSON documents that contain key-value pairs, like:

"casNumber": "96-80-0", 
  "concentration": "<= 100 %", 
  "detailedConcentration": {
    "approximate": false, 
    "fromConcentration": 0, 
    "fromOperand": "", 
    "remainder": false, 
    "toConcentration": 100.0, 
    "toOperand": "<=", 
    "unavailable": false
  }, 
  "ecNumber": "202-536-2", 
  "molecularFormula": "C8H19NO", 
  "molecularWeight": "145.24 g/mol"
```</div>
@masci masci added type:feature New feature or request Contributions wanted! Looking for external contributions labels Apr 21, 2023
@manulpatel
Copy link

How do we plan to accept callables? By defining__call__meathod in class InMemoryDocumentStore OR to make a separate class in of tokenization and define __call__? Or any other apporach is suggested?

@farhanhubble
Copy link

farhanhubble commented May 12, 2023

If we rename bm25_tokenization_regex to something like bm25_tokenize_with to accept either a regex or a callable, it breaks backwards compatibility.

If we introduce a new param it'll muddle up things and we'd need to ensure that both of them don't get used simultaneously.

@anakin87 anakin87 added the 1.x label Feb 16, 2024
@masci masci added 2.x Related to Haystack v2.0 and removed 1.x labels Mar 12, 2024
@CarlosFerLo
Copy link
Contributor

Will try to help with this one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0 Contributions wanted! Looking for external contributions type:feature New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

5 participants