I guess the margin of the win would play a part. Not sure if number of goals or margin matter more.
Assuming we beat Valencia and lose to Lille + Ajax beat Lille and lose to Valencia, that would mean we, Ajax and Valencia have 10 points each at the end of the group stage. If that's the case, then it would come down to the points won in the H2H between the 3 said teams. So taking those scenarios into equation:
Ajax - 4 points (beat Valencia, drew with Chelsea, lost to Valencia & Chelsea)
Chelsea - 7 points (beat Ajax & Valencia, drew with Ajax, lost to Valencia)
Valencia - 6 points (beat Chelsea & Ajax, lost to Chelsea & Ajax)
We would end up finishing top, Valencia in 2nd and Ajax in 3rd.