update README.md
Browse files
README.md
CHANGED
|
@@ -66,44 +66,7 @@ print(enc_path, tte_path, tok_path)
|
|
| 66 |
Required libraries:
|
| 67 |
- `onnxruntime`
|
| 68 |
- `onnxruntime-extensions` (build with `-DOCOS_ENABLE_SPM_TOKENIZER=ON`)
|
| 69 |
-
- `pg_onnx` (
|
| 70 |
-
|
| 71 |
-
Note: To enable SentencePiece tokenizer support, ensure `libortextensions.so` is registered via `RegisterCustomOpsLibrary` in `onnxruntime-server/src/onnx/session.cpp`.
|
| 72 |
-
|
| 73 |
-
``` C++
|
| 74 |
-
Orts::onnx::session::session(session_key key, const std::string &path, const json &option)
|
| 75 |
-
: session(std::move(key), option) {
|
| 76 |
-
#ifdef _WIN32
|
| 77 |
-
int size_needed = MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, NULL, 0);
|
| 78 |
-
std::wstring wstr(size_needed, 0);
|
| 79 |
-
MultiByteToWideChar(CP_ACP, 0, path.c_str(), -1, &wstr[0], size_needed);
|
| 80 |
-
|
| 81 |
-
auto model_path = wstr.c_str();
|
| 82 |
-
#else
|
| 83 |
-
auto model_path = path.c_str();
|
| 84 |
-
#endif
|
| 85 |
-
|
| 86 |
-
void* handle = nullptr;
|
| 87 |
-
const char* ext_path = "libortextensions.so";
|
| 88 |
-
OrtStatus* status = Ort::GetApi().RegisterCustomOpsLibrary(session_options, ext_path, &handle);
|
| 89 |
-
|
| 90 |
-
ort_session = new Ort::Session(env, model_path, session_options);
|
| 91 |
-
init();
|
| 92 |
-
}
|
| 93 |
-
|
| 94 |
-
Orts::onnx::session::session(
|
| 95 |
-
session_key key, const char *model_data, const size_t model_data_length, const json &option
|
| 96 |
-
)
|
| 97 |
-
: session(std::move(key), option) {
|
| 98 |
-
|
| 99 |
-
void* handle = nullptr;
|
| 100 |
-
const char* ext_path = "libortextensions.so";
|
| 101 |
-
OrtStatus* status = Ort::GetApi().RegisterCustomOpsLibrary(session_options, ext_path, &handle);
|
| 102 |
-
|
| 103 |
-
ort_session = new Ort::Session(env, model_data, model_data_length, session_options);
|
| 104 |
-
init();
|
| 105 |
-
}
|
| 106 |
-
```
|
| 107 |
|
| 108 |
-- After building pg_onnx, install the pg_onnx extension
|
| 109 |
``` SQL
|
|
@@ -115,8 +78,8 @@ create extension pg_onnx
|
|
| 115 |
```sql
|
| 116 |
|
| 117 |
-- Register models
|
| 118 |
-
select pg_onnx_import_model('e5-tok', 'v1', pg_read_binary_file('/PATH/tokenizer.onnx')::bytea,
|
| 119 |
-
select pg_onnx_import_model('e5-embedding', 'v1', pg_read_binary_file('/PATH/text_to_embedding.onnx')::bytea,
|
| 120 |
|
| 121 |
-- Create functions
|
| 122 |
create or replace function e5_tok(input_text text)
|
|
|
|
| 66 |
Required libraries:
|
| 67 |
- `onnxruntime`
|
| 68 |
- `onnxruntime-extensions` (build with `-DOCOS_ENABLE_SPM_TOKENIZER=ON`)
|
| 69 |
+
- `pg_onnx` (v1.23.1b or later)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-- After building pg_onnx, install the pg_onnx extension
|
| 72 |
``` SQL
|
|
|
|
| 78 |
```sql
|
| 79 |
|
| 80 |
-- Register models
|
| 81 |
+
select pg_onnx_import_model('e5-tok', 'v1', pg_read_binary_file('/PATH/tokenizer.onnx')::bytea, '{"ortextensions_path": "libortextensions.so"}'::jsonb, 'e5 tokenizer');
|
| 82 |
+
select pg_onnx_import_model('e5-embedding', 'v1', pg_read_binary_file('/PATH/text_to_embedding.onnx')::bytea, '{"ortextensions_path": "libortextensions.so"}'::jsonb, 'e5 text to embedding');
|
| 83 |
|
| 84 |
-- Create functions
|
| 85 |
create or replace function e5_tok(input_text text)
|