Both, but that's an oversimplification. Here's an example: The Torah says, don't work on the Sabbath. But what is work? When exactly does the Sabbath begin and end? For questions like this, the Talmud is useful. The Talmud records the different opinions of a wide variety of rabbis from the time of the Pharisees to about the year 400. When different rabbis disagreed, the Talmud doesn't always say whose opinion wins, so for that, it's useful to look at later commentaries. The arguments about some issues continue to this day: Is it work to turn on or off an electric light on the Sabbath? For that, you need to ask modern rabbis, but their answers (even the from the Reform movement) refer back to the Talmud.