Skip to content

llama integration with exception safety#2

Open
reeshabh90 wants to merge 31 commits into
as-ascii:masterfrom
reeshabh90:llama-integration
Open

llama integration with exception safety#2
reeshabh90 wants to merge 31 commits into
as-ascii:masterfrom
reeshabh90:llama-integration

Conversation

@reeshabh90
Copy link
Copy Markdown

Features worked:

  1. Llama.cpp integration as one of the engines in docwire SDK.
  2. Ensured exception safety for llama_runner class

Comment thread ports/docwire/vcpkg.json
Comment thread src/ai_runner.h Outdated
Comment thread src/CMakeLists.txt
Comment thread src/llama_generation_config.h Outdated
Comment thread src/llama_generation_config.h Outdated
Comment thread src/llama_runner.cpp
Comment thread src/llama_runner.cpp
Comment thread src/llama_runner.cpp Outdated
Comment thread src/llama_runner.cpp Outdated
Comment thread src/llama_runner.cpp Outdated
Comment thread src/c2t_runner.cpp Outdated
Comment thread src/docwire.cpp Outdated
Comment thread src/llama_runner.cpp Outdated
Comment thread src/local_ai.cmake Outdated
Comment thread src/model_inference_config.h Outdated
Comment thread src/model_inference_config_type.h
Comment thread src/model_inference_config_type.h
Comment thread tests/local_ai_llama_integration.cpp Outdated
1. Added configurable model load and unload feature, which gives sdk an
   option to decide whether to unload to the model after pipeline usage
   or keep it persistent for next usage.

2. Added files for local summarize and translate
Comment thread src/ct2_runner.cpp
Comment thread src/c2t_runner.cpp Outdated
Comment thread src/ct2_runner.cpp
Comment thread src/ai_runner.h
Comment thread src/llama_runner.cpp Outdated
Comment thread src/local_ai_translate.cpp Outdated
Comment thread src/local_ai_translate.h Outdated
Comment thread src/local_ai_translate.h Outdated
Comment thread src/local_ai_summarize.h Outdated
Comment thread src/local_ai_summarize.cpp Outdated
Comment thread ports/docwire/vcpkg.json Outdated
Comment thread ports/docwire/vcpkg.json Outdated
Comment thread ports/docwire/vcpkg.json Outdated
Comment thread ports/qwen2-7b-instruct-q4-k-m/portfile.cmake
Comment thread src/cosine_similarity.cpp
Comment thread ports/docwire/vcpkg.json
Comment thread ports/docwire/vcpkg.json Outdated
Comment thread src/cli.cmake Outdated
Comment thread src/docwire.cpp
Comment thread src/local_ai.cmake Outdated
Comment thread src/local_ai.cmake Outdated
Comment thread src/local_ai.cmake Outdated
Comment thread src/local_ai.cmake Outdated
Comment thread tests/api_tests.cpp
Comment thread CMakeLists.txt
Comment thread tests/CMakeLists.txt Outdated
Comment thread tests/integration_example.cpp
Comment thread tests/integration_example.cmake Outdated
Comment thread tests/CMakeLists.txt
Comment thread src/local_ai_translate.h Outdated
Comment thread src/local_ai.cmake Outdated
Comment thread src/llama_runner.h Outdated
Comment thread src/ct2_runner.h Outdated
Comment thread src/ai_runner.h
Comment thread src/docwire.cpp
if (vm.count("local-ai-prompt") || vm.count("local-ai-embed"))
{
std::cerr << "Error: Local AI features requested, but this build does not include "
"DOCWIRE_LOCAL_CT2 support.\n"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little bit counter-intuitive that we need ct2 to use --local-ai-prompt if we have llama.cpp engine enabled. Maybe this option should work with llama.cpp as well?

Copy link
Copy Markdown
Owner

@as-ascii as-ascii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work

Comment thread src/ai_ct2.cmake Outdated
Comment thread src/ai_ct2.cmake Outdated

add_library(docwire_ai_ct2 SHARED ct2_runner.cpp tokenizer.cpp)

target_compile_definitions(docwire_ai_ct2 PUBLIC DOCWIRE_LOCAL_CT2)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? It will always be true i think.

Comment thread src/ai_embed.cpp Outdated
Comment thread src/ai_embed.h Outdated
Comment thread src/ai_llama.cmake Outdated
Comment thread tests/local_ai_find.cpp
Comment thread tests/local_ai_llama_integration.cpp
Comment thread tests/local_ai_sentiment.cpp
Comment thread tests/local_ai_translate.cpp Outdated
Comment thread tests/local_embedding_similarity.cpp Outdated
Copy link
Copy Markdown
Owner

@as-ascii as-ascii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are good in general but not complete yet I think.

Comment thread src/local_ai_embed.h Outdated
Comment thread tests/local_ai_translate.cpp Outdated
Comment thread tests/local_embedding_similarity.cpp Outdated
Comment thread README.md Outdated
Comment thread src/docwire.cpp Outdated
Comment thread src/local_ai_embed.h Outdated
Comment thread src/local_ai_embed.h Outdated
* The appropriate prefix for the underlying model (e.g. "passage: " for multilingual-e5-small)
* is applied automatically. No model-specific knowledge required at the call site.
*/
class DOCWIRE_LOCAL_AI_EXPORT embed_passage : public docwire::ai::embed
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to think about best name. "passage" is not well known in developers community, only for AI experts. I propose "document" or "content" or "index". And maybe embed::query not embed_query? But the concept of two classes instead of enum argument is interesting. Probably shorter: embed::query{} instead of embed{embed::query} so nicer in examples.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current namespace is: docwire::ai::local, may be that needs to be changed to docwire::ai::local:embed and then the two classes. But, is it required? an additional nesting in namespace?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are doing it now but in old C style: embed_X, embed_Y ;-) Its kind of a namespace in my opinion, no? Do you see any cons of converting it to embed::X and embed::Y? I have other doubts about naming: "embed" suggests a function rather than class/object, maybe it should be named "embedder" or "vectorizer"? Maybe it should be query::embedder and index::vectorizer ? Naming is hard for creators but very important for users.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understood.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can follow content_type namespace a little bit, for example index::embedder and query::embedder and then there is a possiblity to add for example index::embed and query::embed functions if user is not building a parsing chain just wanted to use function. I will try to add this kind of things into our "design rules" that are created currently.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, these index::embed and query::embed functions will be separate from usual constructors?
So proposed namespaces can be: docwire::ai:embedder::passage and docwire::ai:embedder::query.

Even content_type namespace, as I see, has main classification name first, and then various iteration of utilities like: docwire::content_type::by_signature, docwire::content_type::asp, docwire::content_type::by_file_extension

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but for example by_signature is a namespace and there is class there "detector" and function "detect". If you will stay with class/object API for now than embedder::index and embedder::query have sense of course but "index" and "query" classes does not look like something that generate index or query but something that is index or query. Naming is hard... "embedder" looks like object that generates embeddings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants