демонстрация семантического поиска с сервером gRPC в Rust
src/hnsw_index
( hnswlib-rs
) из этого проекта и импортируйте его из ящика. std::simd
( packed_simd_2
) Извлеките вложения из заданных документов, создайте и сохраните индекс на локальный диск.
cargo +nightly run --release --features progress --bin embedding
Если вам нужно квантование, передайте quantize
в аргумент.
cargo +nightly run --release --features progress --bin embedding quantize
Создайте и запустите сервер gRPC (для построения модели и поиска).
make server
Создайте и запустите клиент gRPC. Клиент начнет тестировать сервер на основе заданных параметров.
make client
Вы также можете изменить аргументы. например ./client num_users num_requests bs k
cargo +nightly run --release --bin client 1 1000 128 10
Запустите пример с данным запросом. (должен быть встроенный индекс с набором данных ag_news
)
cargo +nightly run --release --features progress --bin main " query "
AVX2
и FMA
% задержки немного отличается от версии Rust. В последней версии (1.73.0 ночная) скорость становится медленнее (2,275 мс -> 3,000 мс).
% i8 сравнивается с версией 1.73.0.
п | расстояние | бс | требования | к | тип | иметь в виду | стр.95 | стр.99 | р99.9 | Макс | количество запросов в секунду |
---|---|---|---|---|---|---|---|---|---|---|---|
ф32 | Л2 | 1 | 10 тысяч | 10 | общий | 4,833 мс | 5,426 мс | 6,037 мс | 9,578 мс | 12,411 мс | 207 |
модель | 4,507 мс | 4,994 мс | 5,505 мс | 8,979 мс | 12,094 мс | ||||||
поиск | 0,203 мс | 0,308 мс | 0,354 мс | 0,449 мс | 0,567 мс | 4926 | |||||
32 | 1 тыс. | 10 | общий | 10,403 мс | 10,951 мс | 11,625 мс | 16,794 мс | 16,794 мс | 3076 | ||
модель | 9,211 мс | 9,684 мс | 10,226 мс | 14,796 мс | 14,796 мс | ||||||
поиск | 0,981 мс | 1,183 мс | 1,386 мс | 2,386 мс | 2,386 мс | 32620 | |||||
128 | 1 тыс. | 10 | общий | 32,220 мс | 32,602 мс | 32,862 мс | 33,440 мс | 33,440 мс | 3973 | ||
модель | 29,120 мс | 29,411 мс | 29,653 мс | 30,333 мс | 30,333 мс | ||||||
поиск | 2,855 мс | 3,007 мс | 3,154 мс | 3,452 мс | 3,452 мс | 44834 | |||||
Потому что | 128 | 1 тыс. | 10 | общий | 31,547 мс | 31,890 мс | 32,087 мс | 33,479 мс | 33,479 мс | 4128 | |
модель | 28,992 мс | 29,229 мс | 29,438 мс | 30,936 мс | 30,936 мс | ||||||
поиск | 2,275 мс | 2,444 мс | 2,595 мс | 2,722 мс | 2,722 мс | 56264 | |||||
i8 | Потому что | 128 | 1 тыс. | 10 | общий | 30,896 мс | 31,271 мс | 31,483 мс | 31,786 мс | 31,786 мс | 4142 |
модель | 28,816 мс | 29,123 мс | 29,286 мс | 29,598 мс | 29,598 мс | 4442 | |||||
поиск | 1,764 мс | 1,934 мс | 2,006 мс | 2,308 мс | 2,308 мс | 72560 |
п | расстояние | бс | требования | к | иметь в виду | стр50 | стр.95 | стр.99 | р99.9 | Макс | количество запросов в секунду |
---|---|---|---|---|---|---|---|---|---|---|---|
ф32 | потому что | 1024 | 2 тыс. | 10 | 10,969 мс | 10,856 мс | 12,078 мс | 12,384 мс | 14,817 мс | 18,024 мс | 93354 |
2048 | 2 тыс. | 10 | 21,829 мс | 21,617 мс | 23,952 мс | 24,514 мс | 25,892 мс | 26,171 мс | 93820 | ||
4096 | 2 тыс. | 10 | 43,538 мс | 43,199 мс | 46,303 мс | 48,374 мс | 50,194 мс | 57,159 мс | 94079 | ||
8192 | 2 тыс. | 10 | 86,234 мс | 85,684 мс | 90,645 мс | 93,850 мс | 101,188 мс | 102,607 мс | 94997 | ||
i8 | потому что | 1024 | 2 тыс. | 10 | 9,102 мс | 9,022 мс | 10,043 мс | 10,222 мс | 11,297 мс | 11,602 мс | 112506 |
2048 | 2 тыс. | 10 | 18,084 мс | 17,867 мс | 19,799 мс | 20,548 мс | 22,749 мс | 29,330 мс | 113249 | ||
4096 | 2 тыс. | 10 | 35,772 мс | 35,488 мс | 38,246 мс | 40,089 мс | 41,745 мс | 43,144 мс | 114503 | ||
8192 | 2 тыс. | 10 | 71,447 мс | 70,790 мс | 76,420 мс | 78,610 мс | 94,783 мс | 122,490 мс | 114659 |
п | расстояние | бс | требования | к | иметь в виду | стр50 | стр.95 | стр.99 | р99.9 | Макс | количество запросов в секунду |
---|---|---|---|---|---|---|---|---|---|---|---|
ф32 | потому что | 1024 | 2 тыс. | 10 | 9,459 мс | 9,033 мс | 11,412 мс | 11,842 мс | 12,753 мс | 12,819 мс | 108252 |
2048 | 2 тыс. | 10 | 19,620 мс | 19,708 мс | 21,072 мс | 22,023 мс | 24,704 мс | 24,881 мс | 104383 | ||
4096 | 2 тыс. | 10 | 38,269 мс | 38,237 мс | 40,505 мс | 42,475 мс | 45,439 мс | 45,691 мс | 107030 | ||
8192 | 2 тыс. | 10 | 75,385 мс | 74,877 мс | 80,448 мс | 84,589 мс | 89,629 мс | 89,887 мс | 108668 | ||
i8 | потому что | 1024 | 2 тыс. | 10 | 7,003 мс | 6,700 мс | 8,270 мс | 8,668 мс | 9,655 мс | 10,011 мс | 146223 |
2048 | 2 тыс. | 10 | 14,388 мс | 14,419 мс | 15,637 мс | 16,067 мс | 19,237 мс | 20,231 мс | 142341 | ||
4096 | 2 тыс. | 10 | 27,894 мс | 27,815 мс | 29,818 мс | 31,213 мс | 39,733 мс | 40,387 мс | 146842 | ||
8192 | 2 тыс. | 10 | 54,674 мс | 54,348 мс | 57,844 мс | 61,486 мс | 100,327 мс | 135,911 мс | 149834 |
Asia shares drift lower as investors factor in Fed rate hike.
Косинусное расстояние
top 1 | id : 92048, dist : 0.3335874
Asian Shares Lower as Oil Fall Stalls SINGAPORE (Reuters) - Asian share markets saw light selling in line with a slowing retreat in oil prices on Tuesday, while the dollar steadied as officials in Europe and Japan fretted about the U.S. currency's recent decline.
top 2 | id : 65687, dist : 0.38142937
Asian Shares Lower on Earnings, Steel SINGAPORE (Reuters) - Asian share markets staged a broad-based retreat on Wednesday, led by steelmakers amid warnings of price declines, but also enveloping technology and financial stocks on worries that earnings may disappoint.
top 3 | id : 15361, dist : 0.39869058
Asian Stocks Mostly Lower on Tech Worries SINGAPORE (Reuters) - Asian shares were mostly lower on Tuesday, pulled down by technology stocks following worries about a sales forecast from bellwether Intel Corp. and unexpectedly flat industrial output in Japan.
top 4 | id : 63234, dist : 0.40184337
Asian Stocks Slip as Oil Moves Above $55 Asian share markets fell on Monday after oil hit a record above $55 a barrel, with investors cautious ahead of earnings reports from bellwether firms IBM and Texas Instruments later in the day.
top 5 | id : 76590, dist : 0.4137212
Asian Stocks Ease After China Rate Rise SINGAPORE (Reuters) - China's surprise interest rate rise weighed down Asian stocks on Friday as investors sold shares of miners, shippers and other firms whose fortunes have been closely linked to the country's rapid growth.
top 6 | id : 65572, dist : 0.4192986
Asian Shares Lower on Earnings SINGAPORE (Reuters) - Asian share markets slumped on Wednesday, led by South Korea's POSCO Co. Ltd. and other steelmakers amid warnings of a drop in prices, and as investors worried that third-quarter earnings may disappoint.
top 7 | id : 14210, dist : 0.41932273
Asian Stocks Mostly Flat to Lower SINGAPORE (Reuters) - Asian shares were mostly flat to lower on Monday as investors kept a wary eye on stabilizing oil prices and looked past signs Japanese consumers were beginning to spend more freely.
top 8 | id : 14904, dist : 0.4203742
European Shares Drift Down in Thin Trade European stocks were slightly lower by mid-day in holiday-hit trading on Monday, with crude oil rises weighing on shares, though Sanofi-Aventis gained on the result of trials of an anti-obesity drug.
top 9 | id : 76632, dist : 0.4244548
Asian Stocks Ease After China Rate Rise (Reuters) Reuters - China's surprise interest rate riseweighed down Asian stocks on Friday as investors sold shares ofminers, shippers and other firms whose fortunes have beenclosely linked to the country's rapid growth.
top 10 | id : 15265, dist : 0.42584515
Asian Stocks Mostly Lower on Tech Worries (Reuters) Reuters - Asian shares were mostly lower onTuesday, pulled down by technology stocks following worriesabout a sales forecast from bellwether Intel Corp. andunexpectedly flat industrial output in Japan.
Расстояние L2
top 1 | id : 92048, dist : 0.667175
Asian Shares Lower as Oil Fall Stalls SINGAPORE (Reuters) - Asian share markets saw light selling in line with a slowing retreat in oil prices on Tuesday, while the dollar steadied as officials in Europe and Japan fretted about the U.S. currency's recent decline.
top 2 | id : 65687, dist : 0.76285875
Asian Shares Lower on Earnings, Steel SINGAPORE (Reuters) - Asian share markets staged a broad-based retreat on Wednesday, led by steelmakers amid warnings of price declines, but also enveloping technology and financial stocks on worries that earnings may disappoint.
top 3 | id : 15361, dist : 0.7973814
Asian Stocks Mostly Lower on Tech Worries SINGAPORE (Reuters) - Asian shares were mostly lower on Tuesday, pulled down by technology stocks following worries about a sales forecast from bellwether Intel Corp. and unexpectedly flat industrial output in Japan.
top 4 | id : 63234, dist : 0.80368686
Asian Stocks Slip as Oil Moves Above $55 Asian share markets fell on Monday after oil hit a record above $55 a barrel, with investors cautious ahead of earnings reports from bellwether firms IBM and Texas Instruments later in the day.
top 5 | id : 76590, dist : 0.82744247
Asian Stocks Ease After China Rate Rise SINGAPORE (Reuters) - China's surprise interest rate rise weighed down Asian stocks on Friday as investors sold shares of miners, shippers and other firms whose fortunes have been closely linked to the country's rapid growth.
top 6 | id : 65572, dist : 0.83859724
Asian Shares Lower on Earnings SINGAPORE (Reuters) - Asian share markets slumped on Wednesday, led by South Korea's POSCO Co. Ltd. and other steelmakers amid warnings of a drop in prices, and as investors worried that third-quarter earnings may disappoint.
top 7 | id : 14210, dist : 0.83864534
Asian Stocks Mostly Flat to Lower SINGAPORE (Reuters) - Asian shares were mostly flat to lower on Monday as investors kept a wary eye on stabilizing oil prices and looked past signs Japanese consumers were beginning to spend more freely.
top 8 | id : 14904, dist : 0.8407483
European Shares Drift Down in Thin Trade European stocks were slightly lower by mid-day in holiday-hit trading on Monday, with crude oil rises weighing on shares, though Sanofi-Aventis gained on the result of trials of an anti-obesity drug.
top 9 | id : 77269, dist : 0.84736
Asian Markets Mixed on China Rate Hike (AP) AP - Asian financial markets showed a mixed reaction Friday to China's first interest rate rise in nine years, which analysts welcomed as a shift toward capitalist-style economic tools and away from central planning.
top 10 | id : 76632, dist : 0.8489096
Asian Stocks Ease After China Rate Rise (Reuters) Reuters - China's surprise interest rate riseweighed down Asian stocks on Friday as investors sold shares ofminers, shippers and other firms whose fortunes have beenclosely linked to the country's rapid growth.
Косинусное расстояние с i8 (не масштабируется)
top 1 | id : 70945, dist : 8807
Asian Shares Fall on Dollar; Gold, Oil Up (Reuters) Reuters - The U.S. dollar stumbled on Monday,setting multi-month lows against the yen and euro and tradingaround four-year lows against the Korean won and Singaporedollar, prompting investors to clip Asian share markets.
top 2 | id : 33140, dist : 10982
US Stock-Index Futures Decline; Citigroup, GE Slip in Europe US stock-index futures declined. Dow Jones Industrial Average shares including General Electric Co. slipped in Europe. Citigroup Inc.
top 3 | id : 33077, dist : 11208
US Stock-Index Futures Are Little Changed; Citigroup, GE Slip US stock-index futures were little changed. Dow Jones Industrial Average shares including General Electric Co. slipped in Europe. Citigroup Inc.
top 4 | id : 95897, dist : 11290
Red hot Google shares cooling Google Inc. may be subject to the law of gravity, after all. Its shares, which more than doubled in the two months after the company's Aug. 19 initial public offering and traded as high as $201.60 on Nov. 3, have slipped about 17 percent over the past two weeks. They closed at $167.54 yesterday, down 2.88 percent for the day, ...
top 5 | id : 40354, dist : 11390
Tokyo stocks open slightly lower TOKYO - Stocks opened slightly lower Monday on the Tokyo Stock Exchange as declines in US technology shares last Friday prompted selling.
top 6 | id : 64025, dist : 12241
E*Trade Profit Rises as Expenses Drop (Reuters) Reuters - E*Trade Financial Corp. , anonline bank and brokerage, on Monday said its third-quarterprofit rose as lower expenses offset a drop in net revenue.
top 7 | id : 58035, dist : 12458
UK inflation rate fall continues The UK's inflation rate fell in September, thanks in part to a fall in the price of airfares, increasing the chance that interest rates will be kept on hold.
top 8 | id : 65573, dist : 12583
Yen Eases Against Dollar TOKYO (Reuters) - The yen edged down against the dollar on Wednesday as Japanese stock prices slid, but it remained within striking distance of three-month highs on persistent concerns about the health of the U.S. economy.
top 9 | id : 50470, dist : 12828
Tower Auto Sees Wider Loss, Shares Fall CHICAGO (Reuters) - Auto parts maker Tower Automotive Inc. <A HREF="http://www.investor.reuters.com/FullQuote.aspx?ticker=TWR.N target=/stocks/quickinfo/fullquote">TWR.N</A> said on Tuesday its third-quarter loss would be twice as deep as previously expected because of lower vehicle production in North America and higher steel costs.
top 10 | id : 1267, dist : 13020
Study: Global Warming Could Change Calif. (AP) AP - Global warming could cause dramatically hotter summers and a depleted snow pack in California, leading to a sharp increase in heat-related deaths and jeopardizing the water supply, according to a study released Monday.
@kozistr