Skip to content
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

Add new nvtext tokenized minhash API #17944

Merged
merged 37 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
491de6b
Add new nvtext tokenized minhash API
davidwendt Feb 7, 2025
efe51d8
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 7, 2025
580f38e
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 7, 2025
c1e805a
fix merge conflict
davidwendt Feb 7, 2025
9e1472b
fix kernel; add minhash64_ngrams, gtest
davidwendt Feb 7, 2025
d31be75
Merge branch 'tokenized-minhash' of github.com:davidwendt/cudf into t…
davidwendt Feb 7, 2025
8c8c7aa
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 7, 2025
8b09c5e
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 10, 2025
49ad728
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 10, 2025
e5afa36
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 11, 2025
66027a9
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 11, 2025
f7e570b
add python interfaces
davidwendt Feb 11, 2025
937c90f
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 11, 2025
1c2d408
fix doxygen, add more gtests
davidwendt Feb 11, 2025
15d14ec
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 11, 2025
b91d80b
Merge branch 'tokenized-minhash' of github.com:davidwendt/cudf into t…
davidwendt Feb 11, 2025
ce4e25f
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 12, 2025
3bf642d
add more gtests
davidwendt Feb 12, 2025
d5f43c9
add pytests
davidwendt Feb 12, 2025
fc70e37
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 12, 2025
add22d9
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 13, 2025
f7e0dbb
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 14, 2025
ba1f903
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 15, 2025
b354de4
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 18, 2025
3bee957
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 18, 2025
51d50e9
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 19, 2025
d235959
change Column to ColumnBase
davidwendt Feb 19, 2025
d7db2dd
change thrust::get to cuda::std::get
davidwendt Feb 19, 2025
ad7e7a4
Merge branch 'tokenized-minhash' of github.com:davidwendt/cudf into t…
davidwendt Feb 19, 2025
827093f
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 20, 2025
504fe94
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 20, 2025
a392ac1
add sliced gtest
davidwendt Feb 21, 2025
e7d77c9
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 21, 2025
32038d1
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 21, 2025
5954543
fix pylibcudf pytest
davidwendt Feb 21, 2025
6e5a567
Merge branch 'tokenized-minhash' of github.com:davidwendt/cudf into t…
davidwendt Feb 24, 2025
00bf07d
Merge branch 'branch-25.04' into tokenized-minhash
davidwendt Feb 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions cpp/include/nvtext/minhash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,99 @@ std::unique_ptr<cudf::column> minhash64(
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Returns the minhash values for each input row
*
* This function uses MurmurHash3_x86_32 for the hash algorithm.
*
* The input row is first hashed using the given `seed` over a sliding window
* of `ngrams` of strings. These hash values are then combined with the `a`
* and `b` parameter values using the following formula:
* ```
* max_hash = max of uint32
* mp = (1 << 61) - 1
* hv[i] = hash value of a ngrams at i
* pv[i] = ((hv[i] * a[i] + b[i]) % mp) & max_hash
* ```
*
* This calculation is performed on each set of ngrams and the minimum value
* is computed as follows:
* ```
* mh[j,i] = min(pv[i]) for all ngrams in row j
* and where i=[0,a.size())
* ```
*
* Any null row entries result in corresponding null output rows.
*
* @throw std::invalid_argument if the ngrams < 2
* @throw std::invalid_argument if parameter_a is empty
* @throw std::invalid_argument if `parameter_b.size() != parameter_a.size()`
* @throw std::overflow_error if `parameter_a.size() * input.size()` exceeds the column size limit
*
* @param input Strings column to compute minhash
* @param ngrams The number of strings to hash within each row
* @param seed Seed value used for the hash algorithm
* @param parameter_a Values used for the permuted calculation
* @param parameter_b Values used for the permuted calculation
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return List column of minhash values for each string per seed
*/
std::unique_ptr<cudf::column> minhash_ngrams(
cudf::lists_column_view const& input,
cudf::size_type ngrams,
uint32_t seed,
cudf::device_span<uint32_t const> parameter_a,
cudf::device_span<uint32_t const> parameter_b,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/**
* @brief Returns the minhash values for each input row
*
* This function uses MurmurHash3_x64_128 for the hash algorithm.
*
* The input row is first hashed using the given `seed` over a sliding window
* of `ngrams` of strings. These hash values are then combined with the `a`
* and `b` parameter values using the following formula:
* ```
* max_hash = max of uint64
* mp = (1 << 61) - 1
* hv[i] = hash value of a ngrams at i
* pv[i] = ((hv[i] * a[i] + b[i]) % mp) & max_hash
* ```
*
* This calculation is performed on each set of ngrams and the minimum value
* is computed as follows:
* ```
* mh[j,i] = min(pv[i]) for all ngrams in row j
* and where i=[0,a.size())
* ```
*
* Any null row entries result in corresponding null output rows.
*
* @throw std::invalid_argument if the ngrams < 2
* @throw std::invalid_argument if parameter_a is empty
* @throw std::invalid_argument if `parameter_b.size() != parameter_a.size()`
* @throw std::overflow_error if `parameter_a.size() * input.size()` exceeds the column size limit
*
* @param input List strings column to compute minhash
* @param ngrams The number of strings to hash within each row
* @param seed Seed value used for the hash algorithm
* @param parameter_a Values used for the permuted calculation
* @param parameter_b Values used for the permuted calculation
* @param stream CUDA stream used for device memory operations and kernel launches
* @param mr Device memory resource used to allocate the returned column's device memory
* @return List column of minhash values for each string per seed
*/
std::unique_ptr<cudf::column> minhash64_ngrams(
cudf::lists_column_view const& input,
cudf::size_type ngrams,
uint64_t seed,
cudf::device_span<uint64_t const> parameter_a,
cudf::device_span<uint64_t const> parameter_b,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = cudf::get_current_device_resource_ref());

/** @} */ // end of group
} // namespace CUDF_EXPORT nvtext
Loading
Loading