-
Notifications
You must be signed in to change notification settings - Fork 77
feat: add generative recommendation tokenizer. #317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,96 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add header like this:
/* Copyright 2025 The xLLM Authors. All Rights Reserved.
Copyright 2024 The ScaleLLM Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://github.com/jd-opensource/xllm/blob/main/LICENSE
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
| std::lock_guard<std::mutex> lock(instance_map_mutex_); | ||
|
|
||
| auto it = instance_map_.find(version); | ||
| if (it == instance_map_.end()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need to find twice from instance_map_? Line25 above has already do this.
|
|
||
| static void DestroyInstance(const std::string& version) { | ||
| std::lock_guard<std::mutex> lock(instance_map_mutex_); | ||
| instance_map_.erase(version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should erase version from instance_version_list_ ?
| path.append(tokenizer_args_.vocab_file()).string(); | ||
|
|
||
| LOG(INFO) << "model_version:" << model_version; | ||
| LOG(INFO) << "vocab_full_path:" << vocab_full_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: :)
LOG(INFO) << "model_version:" << model_version
<< ", vocab_full_path:" << vocab_full_path;
| ->initialize(vocab_full_path)) | ||
| << "Failed to initialize vocab dict from " << vocab_full_path; | ||
| } else { | ||
| LOG(INFO) << "vocab file is not set"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe log(error) or log(fatal) or return false ?
| @@ -0,0 +1,138 @@ | |||
| #include "rec_vocab_dict.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add xllm header
| } | ||
|
|
||
| bool RecVocabDict::get_items_by_tokens(const RecTokenTriple& rec_token_triple, | ||
| std::vector<int64_t>* item_ids) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe use & here is better.
std::vector<int64_t>* item_ids -> const std::vector<int64_t>& item_ids
CHECK(!item_ids.empty());
| @@ -0,0 +1,94 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add xllm header
|
|
||
| /** | ||
| * @brief initialize instance, parse vocab file | ||
| * @param vocab_file vocab file, need full path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we can align the comment format.
// @brief initialize instance, parse vocab file
// @param vocab_file vocab file, need full path
// ...
| @@ -0,0 +1,52 @@ | |||
| #include "rec_tokenizer.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add xllm header
| std::sort(model_weights_files_.begin(), model_weights_files_.end()); | ||
|
|
||
| //@todo: 'false' will be replaced with generative recommendation judgment | ||
| if (false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it doesn't work yet, shouldn't add this logic for now.
No description provided.