-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from oramasearch/feat/code-embeddings
feat: adds custom models
- Loading branch information
Showing
11 changed files
with
440 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
|
||
posting_storage | ||
.idea | ||
.custom_models |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.fastembed_cache | ||
.fastembed_cache | ||
.custom_models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use anyhow::Result; | ||
use embeddings::custom_models::{CustomModel, ModelFileConfig}; | ||
use embeddings::{load_models, OramaModels}; | ||
|
||
fn main() -> Result<()> { | ||
let models = load_models(); | ||
|
||
let embedding = models.embed( | ||
OramaModels::JinaV2BaseCode, | ||
vec![r" | ||
/** | ||
* This method is needed to used because of issues like: https://github.com/askorama/orama/issues/301 | ||
* that issue is caused because the array that is pushed is huge (>100k) | ||
* | ||
* @example | ||
* ```ts | ||
* safeArrayPush(myArray, [1, 2]) | ||
* ``` | ||
*/ | ||
export function safeArrayPush<T>(arr: T[], newArr: T[]): void { | ||
if (newArr.length < MAX_ARGUMENT_FOR_STACK) { | ||
Array.prototype.push.apply(arr, newArr) | ||
} else { | ||
const newArrLength = newArr.length | ||
for (let i = 0; i < newArrLength; i += MAX_ARGUMENT_FOR_STACK) { | ||
Array.prototype.push.apply(arr, newArr.slice(i, i + MAX_ARGUMENT_FOR_STACK)) | ||
} | ||
} | ||
} | ||
".to_string()], | ||
Some(1), | ||
)?; | ||
|
||
dbg!(embedding.first().unwrap()); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.