Groonga
Loading...
Searching...
No Matches
language_model.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2024-2025 Sutou Kouhei <kou@clear-code.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18
19#pragma once
20
21#include <groonga/progress.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
33typedef struct grn_language_model_ grn_language_model;
40typedef struct grn_language_model_inferencer_ grn_language_model_inferencer;
44typedef struct grn_language_model_loader_ grn_language_model_loader;
45
85 const char *model,
86 int64_t model_length);
87
97#define GRN_LANGUAGE_MODEL_LOADER_N_GPU_LAYERS_DEFAULT 999
98
115 int32_t n_gpu_layers);
131
142GRN_API uint32_t
144 grn_language_model *model);
145
157
171
184
203 grn_ctx *ctx,
205 const char *prefix,
206 int64_t prefix_length);
207
225 grn_ctx *ctx,
228 void *user_data);
229
249 grn_ctx *ctx,
251 const char *text,
252 int64_t text_length,
253 grn_obj *output_vector);
254
275 grn_ctx *ctx,
277 grn_obj *input_column,
278 grn_applier_data *data);
279
340 grn_ctx *ctx,
342 grn_table_cursor *cursor,
343 grn_obj *input_column,
344 grn_obj *output);
345
346#ifdef __cplusplus
347}
348#endif
struct _grn_applier_data grn_applier_data
Definition applier.h:27
grn_rc
Definition groonga.h:61
#define GRN_API
Definition groonga.h:39
GRN_API grn_rc grn_language_model_inferencer_set_input_column_value_prefix(grn_ctx *ctx, grn_language_model_inferencer *inferencer, const char *prefix, int64_t prefix_length)
Prepend prefix to all values of input_column in grn_language_model_inferencer_vectorize_in_batch and ...
GRN_API uint32_t grn_language_model_get_n_embedding_dimensions(grn_ctx *ctx, grn_language_model *model)
Get the number of dimensions of embedding generated by this model.
GRN_API grn_rc grn_language_model_loader_close(grn_ctx *ctx, grn_language_model_loader *loader)
Close a language model loader.
GRN_API grn_rc grn_language_model_inferencer_vectorize(grn_ctx *ctx, grn_language_model_inferencer *inferencer, const char *text, int64_t text_length, grn_obj *output_vector)
Vectorize a text.
struct grn_language_model_loader_ grn_language_model_loader
Language model loader.
Definition language_model.h:44
GRN_API grn_language_model_loader * grn_language_model_loader_open(grn_ctx *ctx)
Open a new language model loader.
GRN_API grn_rc grn_language_model_loader_set_model(grn_ctx *ctx, grn_language_model_loader *loader, const char *model, int64_t model_length)
Set language model name to load.
struct grn_language_model_ grn_language_model
Language model.
Definition language_model.h:33
GRN_API grn_rc grn_language_model_inferencer_close(grn_ctx *ctx, grn_language_model_inferencer *inferencer)
Close a language model inferencer.
GRN_API grn_rc grn_language_model_loader_set_n_gpu_layers(grn_ctx *ctx, grn_language_model_loader *loader, int32_t n_gpu_layers)
Set the number of GPU layers to use.
GRN_API grn_rc grn_language_model_inferencer_set_progress_callback(grn_ctx *ctx, grn_language_model_inferencer *inferencer, grn_progress_callback_func callback, void *user_data)
Set progress callback that is called on each batch vectorization is completed.
GRN_API grn_language_model_inferencer * grn_language_model_open_inferencer(grn_ctx *ctx, grn_language_model *model)
Open a new language model inferencer.
GRN_API grn_rc grn_language_model_inferencer_vectorize_applier(grn_ctx *ctx, grn_language_model_inferencer *inferencer, grn_obj *input_column, grn_applier_data *data)
Vectorize texts in batch.
struct grn_language_model_inferencer_ grn_language_model_inferencer
Language model inferencer.
Definition language_model.h:40
GRN_API grn_rc grn_language_model_close(grn_ctx *ctx, grn_language_model *model)
Close a language model.
GRN_API grn_language_model * grn_language_model_loader_load(grn_ctx *ctx, grn_language_model_loader *loader)
Load a language model.
GRN_API grn_rc grn_language_model_inferencer_vectorize_in_batch(grn_ctx *ctx, grn_language_model_inferencer *inferencer, grn_table_cursor *cursor, grn_obj *input_column, grn_obj *output)
Vectorize texts and output embeddings set to Float32 GRN_UVECTOR or vector column in batch.
void(* grn_progress_callback_func)(grn_ctx *ctx, grn_progress *progress, void *user_data)
Definition progress.h:66
Definition groonga.h:351
Definition groonga.h:919