Skip to content

Commit 1370d5f

Browse files
authored
README NameGraph modes (#331)
* added brief modes description * removed mode from endpoints, where it is unused, added descriptions
1 parent 2713aad commit 1370d5f

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

collection_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ class CollectionSearchByString(BaseCollectionSearchWithOther): # instant search
108108
query: str = Field(title='input query (with or without spaces) which is used to search for template collections',
109109
description='can not contain dots (.)',
110110
pattern='^[^.]+$', examples=['zeus god'])
111-
mode: str = Field('instant', title='request mode: instant, domain_detail', pattern=r'^(instant|domain_detail)$')
111+
mode: str = Field('instant', title='request mode: instant, domain_detail', pattern=r'^(instant|domain_detail)$',
112+
description='* if instant - Learning to Rank is using a window size of 20\n'
113+
'* if domain_detail - Learning to Rank is using a window size of 100')
112114
sort_order: Literal[SortOrder.AZ, SortOrder.ZA, SortOrder.AI, SortOrder.RELEVANCE] = Field(SortOrder.AI, title='order of the resulting collections',
113115
description='* if A-Z or Z-A - sort by title (alphabetically ascending/descending)\n'
114116
'* if AI - use intelligent endpoint-specific ranking (with Learning to Rank for optimal results)\n'
@@ -129,7 +131,6 @@ class CollectionCountByStringRequest(BaseCollectionRequest):
129131
query: str = Field(title='input query (with or without spaces) which is used to search for template collections',
130132
description='can not contain dots (.)',
131133
pattern='^[^.]+$', examples=['zeus god'])
132-
mode: str = Field('instant', title='request mode: instant, domain_detail', pattern=r'^(instant|domain_detail)$')
133134

134135

135136
# ======== Collection Membership ========
@@ -145,7 +146,6 @@ class CollectionsContainingLabelCountResponse(BaseCollectionQueryResponse):
145146

146147
class CollectionsContainingLabelRequest(BaseCollectionSearchLimitOffsetSort):
147148
label: str = Field(title='label for which membership will be checked for each collection', examples=['zeus'])
148-
mode: str = Field('instant', title='request mode: instant, domain_detail', pattern=r'^(instant|domain_detail)$')
149149
max_results: int = Field(3, ge=0, title='max number of collections to return (for each page)',
150150
description='return collections at [offset, offset + max_results) positions (order as in sort_order)')
151151
sort_order: Literal[SortOrder.AZ, SortOrder.ZA, SortOrder.AI, SortOrder.RELEVANCE] = Field(SortOrder.AI, title='order of the resulting collections',

models.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ class Params(BaseModel):
7070
examples=['us'])
7171
mode: str = Field('full', title='request mode: instant, domain_detail, full',
7272
pattern=r'^(instant|domain_detail|full)$',
73-
description='for /grouped_by_category endpoint this field will be prefixed with "grouped_"')
73+
description='modifies global limits and sampling weights of different generators:\n'
74+
'* instant - fastest response, basic generators only\n'
75+
'* domain_detail - balanced speed/quality, expanded search\n'
76+
'* full - comprehensive generation with all generators (recommended)\n'
77+
'(for /grouped_by_category endpoint this field will be prefixed with "grouped_")')
7478
enable_learning_to_rank: bool = Field(True, title='enable learning to rank',
7579
description='if true, the results will be sorted by '
7680
'learning to rank algorithm')
@@ -88,7 +92,11 @@ class GroupedParams(BaseModel):
8892
user_info: Optional[UserInfo] = Field(None, title='information about user making request')
8993
mode: str = Field('full', title='request mode: instant, domain_detail, full',
9094
pattern=r'^(instant|domain_detail|full)$',
91-
description='for /grouped_by_category endpoint this field will be prefixed with "grouped_"')
95+
description='modifies global limits and sampling weights of different generators:\n'
96+
'* instant - fastest response, basic generators only\n'
97+
'* domain_detail - balanced speed/quality, expanded search\n'
98+
'* full - comprehensive generation with all generators (recommended)\n'
99+
'(for /grouped_by_category endpoint this field will be prefixed with "grouped_")')
92100
metadata: bool = Field(True, title='return all the metadata in response')
93101

94102

namegraph/xcollections/api_matcher.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def search_by_string(
100100
logger.error(f'Elasticsearch search failed [by-string]', exc_info=True)
101101
raise HTTPException(status_code=503, detail=str(ex)) from ex
102102

103-
def get_collections_count_by_string(self, query: str, mode: str) -> tuple[Union[int, str], dict]:
103+
def get_collections_count_by_string(self, query: str) -> tuple[Union[int, str], dict]:
104104
tokenized_query = ' '.join(self.tokenizer.tokenize(query)[0])
105105
if tokenized_query != query:
106106
query = f'{query} {tokenized_query}'

readme.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ Authorize to ECR:
9797

9898
Push image to ECR:
9999

100-
`docker push 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator:${TAG}
100+
`docker push 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator:${TAG}`
101101

102102
## Deploy image on remote instance
103103

104104
Set image TAG:
105105

106-
`export TAG=0.1.0
106+
`export TAG=0.1.0`
107107

108108
Authorize EC2 instance in ECR:
109109

@@ -143,6 +143,29 @@ In `conf/pipelines/prod_new.yaml` are defined pipelines. Each pipeline have:
143143

144144
Setting `0` in `mode_weights_multiplier` or `global_limits` disables the pipeline in a given mode.
145145

146+
### Modes
147+
148+
NameGraph supports three modes for processing requests:
149+
150+
- Instant Mode (`instant`):
151+
- Fastest response time
152+
- More basic name generations
153+
- Some advanced generators like W2VGenerator are disabled (weight multiplier = 0)
154+
- Often used for real-time suggestions
155+
156+
- Domain Detail Mode (`domain_detail`):
157+
- Intermediate between instant and full
158+
- More comprehensive than instant, but still optimized for performance
159+
- Some generators have reduced weights compared to full mode
160+
- Expanded search window for collection ranking and sampling
161+
162+
- Full Mode (`full`):
163+
- Most comprehensive name generation
164+
- Includes all enabled generators
165+
- Uses full weights for most generators
166+
- Accesses advanced generators like `Wikipedia2VGenerator` and `W2VGenerator`
167+
- Takes longer to process, but provides the most diverse results
168+
146169
### Sampler
147170

148171
Each request defines:

web_api.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ async def get_collections_count_by_string(query: CollectionCountByStringRequest)
512512
count = 0
513513
es_response_metadata = {'n_total_hits': 0}
514514
else:
515-
count, es_response_metadata = collections_matcher.get_collections_count_by_string(query.query,
516-
mode=query.mode)
515+
count, es_response_metadata = collections_matcher.get_collections_count_by_string(query.query)
517516

518517
time_elapsed = (perf_counter() - t_before) * 1000
519518

0 commit comments

Comments
 (0)