<jupyter_start><jupyter_text>支持的数据集<jupyter_code>import recstudio.data as recdata
print(recdata.supported_dataset)<jupyter_output>['ml-20m', 'gowalla', 'tmall', 'amazon-beauty', 'amazon-electronics', 'ml-1m', 'amazon-books', 'ml-10m', 'ml-100k']<jupyter_text>入门级<jupyter_code>from recstudio import quickstart

quickstart.run(model='SASRec', dataset='ml-100k', gpu=[2])<jupyter_output>[2022-06-02 16:53:58] INFO Global seed set to 2022
[2022-06-02 16:53:58] INFO dataset is read from ../datasets/ml-100k.
/data1/home/huangxu/miniconda3/lib/python3.9/site-packages/pandas/io/parsers/readers.py:586: ParserWarning: Length of header or names does not match length of data. This leads to a loss of data with index_col=False.
  return _read(filepath_or_buffer, kwds)
[2022-06-02 16:53:58] INFO 
[1;32mDataset Info[0m: 

===========================================================================================
[1;34mitem information: 
[0m[1;33mfield[0m        item_id      movie_title  release_year class        
[1;33mtype[0m         token        token_seq    token        token_seq    
[1;33m##[0m           1683         2653         74           20           
===========================================================================================
[1;34muser information: 
[0m[1;33mfield[0m        user_id      age          gender       occupation   
[1;33mtype[0m [...]<jupyter_text>基础级<jupyter_code>import torch
from recstudio.ann import sampler
from recstudio.data import dataset
from recstudio.model.basemodel import BaseRetriever
from recstudio.model import scorer, loss_func as loss
ml_1m_data = dataset.MFDataset(name='ml-1m')

trn, val, tst = ml_1m_data.build(split_ratio=[0.7, 0.2, 0.1])

bpr = BaseRetriever(
    item_encoder = torch.nn.Embedding(trn.num_items, 64, 0),
    query_encoder = torch.nn.Embedding(trn.num_users, 64, 0),
    scorer = scorer.InnerProductScorer(),
    loss = loss.BPRLoss(),
    sampler = sampler.UniformSampler(trn.num_items-1)
)

bpr.fit(trn, val, negative_count=1)

bpr.evaluate(tst)<jupyter_output>[2022-06-02 16:56:44] INFO Load dataset from cache.
[2022-06-02 16:56:45] INFO Global seed set to 2022
[2022-06-02 16:56:45] INFO save_dir:/data1/home/huangxu/work/RecStudio_v2/Recstudio/example
[2022-06-02 16:56:45] INFO BaseRetriever(
  (loss_fn): BPRLoss()
  (item_encoder): Embedding(3884, 64, padding_idx=0)
  (query_encoder): Embedding(6041, 64, padding_idx=0)
  (score_func): InnerProductScorer()
  (sampler): UniformSampler()
)
[2022-06-02 16:56:49] INFO [1;32mTraining: [0m[1;34mEpoch[0m=[1;33m  0[0m [[1;34mrecall@10[0m=[1;33m0.0094[0m [1;34mndcg@10[0m=[1;33m0.0345[0m [1;34mtrain_loss[0m=[1;33m0.6931[0m]
[2022-06-02 16:56:49] INFO Train time: 0.73955s. Valid time: 0.91873s
[2022-06-02 16:56:49] INFO recall@10 improved. Best value: 0.0094
[2022-06-02 16:56:50] INFO [1;32mTraining: [0m[1;34mEpoch[0m=[1;33m  1[0m [[1;34mrecall@10[0m=[1;33m0.0652[0m [1;34mndcg@10[0m=[1;33m0.1836[0m [1;34mtrain_loss[0m=[1;33m0.6795[0m]
[2022-06-02 16:56:50] INFO Train[...]
{'fraction_non_alphanumeric': 0.21260613977792292, 'fraction_numerical': 0.1325930764206401, 'mean_word_length': 5.101593625498008, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '288597', 'license': 'MIT', 'n_tokens_mistral': 1507, 'n_tokens_neox': 1244, 'n_words': 212, 'path': 'example/example.ipynb', 'repo_name': 'ustc-recsys/Torchrec', 'size': '3062'}