Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Semantic Router
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
aurelio-labs
Semantic Router
Commits
da1ff80e
Commit
da1ff80e
authored
1 year ago
by
hananel
Browse files
Options
Downloads
Patches
Plain Diff
make all type hints lowercase
parent
df4a3a8b
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
semantic_router/encoders/fastembed.py
+3
-3
3 additions, 3 deletions
semantic_router/encoders/fastembed.py
semantic_router/linear.py
+1
-3
1 addition, 3 deletions
semantic_router/linear.py
semantic_router/utils/splitters.py
+1
-1
1 addition, 1 deletion
semantic_router/utils/splitters.py
with
5 additions
and
7 deletions
semantic_router/encoders/fastembed.py
+
3
−
3
View file @
da1ff80e
from
typing
import
Any
,
List
,
Optional
from
typing
import
Any
,
Optional
import
numpy
as
np
import
numpy
as
np
from
pydantic
import
PrivateAttr
from
pydantic
import
PrivateAttr
...
@@ -44,8 +44,8 @@ class FastEmbedEncoder(BaseEncoder):
...
@@ -44,8 +44,8 @@ class FastEmbedEncoder(BaseEncoder):
def
__call__
(
self
,
docs
:
list
[
str
])
->
list
[
list
[
float
]]:
def
__call__
(
self
,
docs
:
list
[
str
])
->
list
[
list
[
float
]]:
try
:
try
:
embeds
:
L
ist
[
np
.
ndarray
]
=
list
(
self
.
_client
.
embed
(
docs
))
embeds
:
l
ist
[
np
.
ndarray
]
=
list
(
self
.
_client
.
embed
(
docs
))
embeddings
:
L
ist
[
L
ist
[
float
]]
=
[
e
.
tolist
()
for
e
in
embeds
]
embeddings
:
l
ist
[
l
ist
[
float
]]
=
[
e
.
tolist
()
for
e
in
embeds
]
return
embeddings
return
embeddings
except
Exception
as
e
:
except
Exception
as
e
:
raise
ValueError
(
f
"
FastEmbed embed failed. Error:
{
e
}
"
)
raise
ValueError
(
f
"
FastEmbed embed failed. Error:
{
e
}
"
)
This diff is collapsed.
Click to expand it.
semantic_router/linear.py
+
1
−
3
View file @
da1ff80e
from
typing
import
Tuple
import
numpy
as
np
import
numpy
as
np
from
numpy.linalg
import
norm
from
numpy.linalg
import
norm
...
@@ -21,7 +19,7 @@ def similarity_matrix(xq: np.ndarray, index: np.ndarray) -> np.ndarray:
...
@@ -21,7 +19,7 @@ def similarity_matrix(xq: np.ndarray, index: np.ndarray) -> np.ndarray:
return
sim
return
sim
def
top_scores
(
sim
:
np
.
ndarray
,
top_k
:
int
=
5
)
->
T
uple
[
np
.
ndarray
,
np
.
ndarray
]:
def
top_scores
(
sim
:
np
.
ndarray
,
top_k
:
int
=
5
)
->
t
uple
[
np
.
ndarray
,
np
.
ndarray
]:
# get indices of top_k records
# get indices of top_k records
top_k
=
min
(
top_k
,
sim
.
shape
[
0
])
top_k
=
min
(
top_k
,
sim
.
shape
[
0
])
idx
=
np
.
argpartition
(
sim
,
-
top_k
)[
-
top_k
:]
idx
=
np
.
argpartition
(
sim
,
-
top_k
)[
-
top_k
:]
...
...
This diff is collapsed.
Click to expand it.
semantic_router/utils/splitters.py
+
1
−
1
View file @
da1ff80e
...
@@ -26,7 +26,7 @@ def semantic_splitter(
...
@@ -26,7 +26,7 @@ def semantic_splitter(
split_method (str): The method to use for splitting.
split_method (str): The method to use for splitting.
Returns:
Returns:
D
ict[str, list[str]]: Splits with corresponding documents.
d
ict[str, list[str]]: Splits with corresponding documents.
"""
"""
total_docs
=
len
(
docs
)
total_docs
=
len
(
docs
)
splits
=
{}
splits
=
{}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment