{"id":13586278,"url":"https://github.com/tensorflow/recommenders","last_synced_at":"2026-01-08T00:10:44.180Z","repository":{"id":37057943,"uuid":"275252389","full_name":"tensorflow/recommenders","owner":"tensorflow","description":"TensorFlow Recommenders is a library for building recommender system models using TensorFlow.","archived":false,"fork":false,"pushed_at":"2025-01-16T19:27:43.000Z","size":1952,"stargazers_count":1925,"open_issues_count":275,"forks_count":289,"subscribers_count":49,"default_branch":"main","last_synced_at":"2025-04-13T00:59:12.448Z","etag":null,"topics":["recommender","recommender-system","tensorflow","tensorflow-recommenders"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tensorflow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-06-26T21:38:01.000Z","updated_at":"2025-04-10T07:45:46.000Z","dependencies_parsed_at":"2023-02-18T02:30:48.473Z","dependency_job_id":"684f8f01-0533-4e7c-b177-32d3d68219f7","html_url":"https://github.com/tensorflow/recommenders","commit_stats":{"total_commits":329,"total_committers":43,"mean_commits":7.651162790697675,"dds":0.60790273556231,"last_synced_commit":"151a970f04760cbfe075689a2706386355ff2f53"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Frecommenders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Frecommenders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Frecommenders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tensorflow%2Frecommenders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tensorflow","download_url":"https://codeload.github.com/tensorflow/recommenders/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250478784,"owners_count":21437237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["recommender","recommender-system","tensorflow","tensorflow-recommenders"],"created_at":"2024-08-01T15:05:26.764Z","updated_at":"2026-01-08T00:10:44.143Z","avatar_url":"https://github.com/tensorflow.png","language":"Python","readme":"# TensorFlow Recommenders\n\n![TensorFlow Recommenders logo](assets/full_logo.png)\n\n![TensorFlow Recommenders build badge](https://github.com/tensorflow/recommenders/actions/workflows/test.yaml/badge.svg)\n[![PyPI badge](https://img.shields.io/pypi/v/tensorflow-recommenders.svg)](https://pypi.python.org/pypi/tensorflow-recommenders/)\n\nTensorFlow Recommenders is a library for building recommender system models\nusing [TensorFlow](https://www.tensorflow.org).\n\nIt helps with the full workflow of building a recommender system: data\npreparation, model formulation, training, evaluation, and deployment.\n\nIt's built on Keras and aims to have a gentle learning curve while still giving\nyou the flexibility to build complex models.\n\n## Installation\n\nMake sure you have TensorFlow 2.x installed, and install from `pip`:\n\n```shell\npip install tensorflow-recommenders\n```\n\n## Documentation\n\nHave a look at our\n[tutorials](https://tensorflow.org/recommenders/examples/quickstart) and\n[API reference](https://www.tensorflow.org/recommenders/api_docs/python/tfrs/).\n\n## Quick start\n\nBuilding a factorization model for the Movielens 100K dataset is very simple\n([Colab](https://tensorflow.org/recommenders/examples/quickstart)):\n\n```python\nfrom typing import Dict, Text\n\nimport tensorflow as tf\nimport tensorflow_datasets as tfds\nimport tensorflow_recommenders as tfrs\n\n# Ratings data.\nratings = tfds.load('movielens/100k-ratings', split=\"train\")\n# Features of all the available movies.\nmovies = tfds.load('movielens/100k-movies', split=\"train\")\n\n# Select the basic features.\nratings = ratings.map(lambda x: {\n    \"movie_id\": tf.strings.to_number(x[\"movie_id\"]),\n    \"user_id\": tf.strings.to_number(x[\"user_id\"])\n})\nmovies = movies.map(lambda x: tf.strings.to_number(x[\"movie_id\"]))\n\n# Build a model.\nclass Model(tfrs.Model):\n\n  def __init__(self):\n    super().__init__()\n\n    # Set up user representation.\n    self.user_model = tf.keras.layers.Embedding(\n        input_dim=2000, output_dim=64)\n    # Set up movie representation.\n    self.item_model = tf.keras.layers.Embedding(\n        input_dim=2000, output_dim=64)\n    # Set up a retrieval task and evaluation metrics over the\n    # entire dataset of candidates.\n    self.task = tfrs.tasks.Retrieval(\n        metrics=tfrs.metrics.FactorizedTopK(\n            candidates=movies.batch(128).map(self.item_model)\n        )\n    )\n\n  def compute_loss(self, features: Dict[Text, tf.Tensor], training=False) -\u003e tf.Tensor:\n\n    user_embeddings = self.user_model(features[\"user_id\"])\n    movie_embeddings = self.item_model(features[\"movie_id\"])\n\n    return self.task(user_embeddings, movie_embeddings)\n\n\nmodel = Model()\nmodel.compile(optimizer=tf.keras.optimizers.Adagrad(0.5))\n\n# Randomly shuffle data and split between train and test.\ntf.random.set_seed(42)\nshuffled = ratings.shuffle(100_000, seed=42, reshuffle_each_iteration=False)\n\ntrain = shuffled.take(80_000)\ntest = shuffled.skip(80_000).take(20_000)\n\n# Train.\nmodel.fit(train.batch(4096), epochs=5)\n\n# Evaluate.\nmodel.evaluate(test.batch(4096), return_dict=True)\n```\n","funding_links":[],"categories":["Python","Learning-to-Rank \u0026 Recommender Systems","Deep Learning Framework","推荐系统","推荐系统算法库与列表","Recommendation"],"sub_categories":["Others","High-Level DL APIs","网络服务_其他","Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Frecommenders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftensorflow%2Frecommenders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftensorflow%2Frecommenders/lists"}